query: Add a hint for the TypeError unhashable type: 'set'
.
This commit is contained in:
parent
39a9d0d67e
commit
69f3e4ee6e
2 changed files with 27 additions and 10 deletions
|
@ -556,15 +556,12 @@ class BQLShell(bc_query_shell.BQLShell):
|
||||||
)
|
)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
logger.error(str(error), exc_info=logger.isEnabledFor(logging.DEBUG))
|
logger.error(str(error), exc_info=logger.isEnabledFor(logging.DEBUG))
|
||||||
if (isinstance(error, TypeError)
|
try:
|
||||||
and error.args
|
hint_func = getattr(self, f'_hint_{type(error).__name__}')
|
||||||
and ' not supported between instances ' in error.args[0]):
|
except AttributeError:
|
||||||
logger.info(
|
pass
|
||||||
"HINT: Are you using ORDER BY or comparisons with metadata "
|
else:
|
||||||
"that isn't consistently set?\n "
|
hint_func(error, statement)
|
||||||
"Try looking up that metadata with str_meta() instead to "
|
|
||||||
"ensure your comparisons use a consistent data type.",
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not rows and output_format != 'ods':
|
if not rows and output_format != 'ods':
|
||||||
|
@ -573,6 +570,26 @@ class BQLShell(bc_query_shell.BQLShell):
|
||||||
logger.debug("rendering query as %s", output_format)
|
logger.debug("rendering query as %s", output_format)
|
||||||
render_func(statement, row_types, rows)
|
render_func(statement, row_types, rows)
|
||||||
|
|
||||||
|
def _hint_TypeError(self, error: TypeError, statement: QueryStatement) -> None:
|
||||||
|
try:
|
||||||
|
errmsg = str(error.args[0])
|
||||||
|
except IndexError:
|
||||||
|
return
|
||||||
|
if ' not supported between instances ' in errmsg:
|
||||||
|
logger.info(
|
||||||
|
"HINT: Are you using ORDER BY or comparisons with metadata "
|
||||||
|
"that isn't consistently set?\n "
|
||||||
|
"Try looking up that metadata with str_meta() instead to "
|
||||||
|
"ensure your comparisons use a consistent data type.",
|
||||||
|
)
|
||||||
|
elif errmsg.startswith('unhashable type: '):
|
||||||
|
logger.info(
|
||||||
|
"HINT: bean-query does not support selecting columns or "
|
||||||
|
"functions that return multiple items as non-aggregate data in "
|
||||||
|
"GROUP BY queries.\n "
|
||||||
|
"If you want to aggregate that data, run it through set().",
|
||||||
|
)
|
||||||
|
|
||||||
def _render_csv(self, statement: QueryStatement, row_types: RowTypes, rows: Rows) -> None:
|
def _render_csv(self, statement: QueryStatement, row_types: RowTypes, rows: Rows) -> None:
|
||||||
bc_query_render.render_csv(
|
bc_query_render.render_csv(
|
||||||
row_types,
|
row_types,
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='conservancy_beancount',
|
name='conservancy_beancount',
|
||||||
description="Plugin, library, and reports for reading Conservancy's books",
|
description="Plugin, library, and reports for reading Conservancy's books",
|
||||||
version='1.19.3',
|
version='1.19.4',
|
||||||
author='Software Freedom Conservancy',
|
author='Software Freedom Conservancy',
|
||||||
author_email='info@sfconservancy.org',
|
author_email='info@sfconservancy.org',
|
||||||
license='GNU AGPLv3+',
|
license='GNU AGPLv3+',
|
||||||
|
|
Loading…
Reference in a new issue