Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a helpful error message on "Row size too large" #234

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion commcare_export/env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import hashlib
import json
import logging
import operator
import sys
import uuid
from typing import Any, Dict, Union, overload

Expand All @@ -12,6 +14,8 @@
from jsonpath_ng import jsonpath
from jsonpath_ng.parser import parse as parse_jsonpath

logger = logging.getLogger(__name__)

JSONPATH_CACHE = {}


Expand Down Expand Up @@ -590,7 +594,23 @@ def lookup(self, key):
def emit_table(self, table_spec):
self.emitted = True
table_spec.rows = self._unwrap_row_vals(table_spec.rows)
self.writer.write_table(table_spec)
try:
self.writer.write_table(table_spec)
except Exception as err:
if (
not logger.isEnabledFor(logging.DEBUG) # not --verbose
and 'Row size too large' in str(err)
):
logging.error(
'Row size too large. The amount of data required by rows '
'is more than this type of database table allows. One '
'way to resolve this error is to reduce the number of '
'columns that you are exporting. A general guideline is '
'not to exceed 200 columns.'
)
sys.exit(1)
else:
raise

def has_emitted_tables(self):
return self.emitted
Expand Down
Loading