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

DynamoDB Chart Failure #29920

Open
3 tasks done
noahabbott123 opened this issue Aug 12, 2024 · 1 comment
Open
3 tasks done

DynamoDB Chart Failure #29920

noahabbott123 opened this issue Aug 12, 2024 · 1 comment
Labels
data:connect:dynamodb sqllab Namespace | Anything related to the SQL Lab viz:charts Namespace | Anything related to viz types

Comments

@noahabbott123
Copy link

Bug description

Very basic column retrieval from a DynamoDB table with numbers results in a failure in any Chart function.

How to reproduce the bug

  1. Setup Dynamo DB connector
  2. Run query in SQL Lab
  3. Click "Create Chart"
  4. Any preview, chart, configuration gives the error "Error: Expected table, found '(' (at char 28), (line:3, col:3)"

Screenshots/recordings

Here is the stack trace:
2024-08-12 16:53:18,496:WARNING:superset.models.helpers:Query SELECT COUNT(*) FROM (SELECT NUMBER(TotalAlerts) FROM AlertsMetrics) AS virtual_table LIMIT 50000 on schema default failed Traceback (most recent call last): File "/app/superset/models/helpers.py", line 1032, in exc_query df = self.database.get_df(sql, self.schema, mutator=assign_column_label) File "/app/superset/models/core.py", line 604, in get_df self.db_engine_spec.execute(cursor, sqls[-1]) File "/app/superset/db_engine_specs/base.py", line 1599, in execute raise cls.get_dbapi_mapped_exception(ex) from ex File "/app/superset/db_engine_specs/base.py", line 1597, in execute cursor.execute(query) File "/app/superset_home/.local/lib/python3.10/site-packages/pydynamodb/util.py", line 23, in _wrapper return wrapped(*args, **kwargs) File "/app/superset_home/.local/lib/python3.10/site-packages/pydynamodb/cursor.py", line 85, in execute statement = Statement(operation) File "/app/superset_home/.local/lib/python3.10/site-packages/pydynamodb/model.py", line 172, in __init__ self._api_request = self._sql_parser.transform() File "/app/superset_home/.local/lib/python3.10/site-packages/pydynamodb/sql/parser.py", line 108, in transform return self.parser.transform() File "/app/superset_home/.local/lib/python3.10/site-packages/pydynamodb/sql/dml_select.py", line 171, in transform table_name_ = self.root_parse_results["table"] File "/app/superset_home/.local/lib/python3.10/site-packages/pydynamodb/sql/base.py", line 34, in root_parse_results self._root_parse_results = self.syntax_def.parseString(self._executed_statement) File "/usr/local/lib/python3.10/site-packages/pyparsing/core.py", line 1127, in parse_string raise exc.with_traceback(None) pyparsing.exceptions.ParseException: Expected CaselessKeyword 'FROM', found '(' (at char 12), (line:1, col:13)

Superset version

master / latest-dev

Python version

Not applicable

Node version

16

Browser

Not applicable

Additional context

Running in K8 cluster.

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added sqllab Namespace | Anything related to the SQL Lab viz:charts Namespace | Anything related to viz types labels Aug 12, 2024
Copy link

dosubot bot commented Aug 12, 2024

Hey @noahabbott123! 👋 I'm here to help you with any bugs, questions, or contributions you have for the repository. I'm Dosu, a bot that's eager to assist you.

To resolve the error "Expected table, found '(' (at char 28), (line:3, col:3)" when creating a chart from a basic column retrieval in a DynamoDB table with numbers, you need to ensure that the SQL query or expression you are using is correctly formatted and does not contain any syntax errors.

Here is a step-by-step approach to troubleshoot and resolve the issue:

  1. Check the SQL Expression: Ensure that the SQL expression used in the chart configuration is correct. For example, if you are using a custom expression, make sure it follows the correct syntax.

  2. Validate Column Names and Types: Ensure that the column names and types in your DynamoDB table match those expected by the chart configuration. For example, if you are using a column named TotalAlerts, ensure it is correctly defined as a numeric type.

  3. Review the Chart Configuration: Verify that the chart configuration in Superset is correctly set up. For example, ensure that the groupby and metrics fields are correctly specified.

Here is an example of a correctly formatted SQL expression for a metric:

SELECT COUNT(*)
FROM AlertsMetrics

And here is an example of a correctly configured chart configuration in JSON format:

{
  "datasource": "3__table",
  "viz_type": "table",
  "slice_id": 86,
  "include_search": true,
  "url_params": {},
  "granularity_sqla": "ds",
  "time_grain_sqla": "P3M",
  "time_range": "No filter",
  "query_mode": "aggregate",
  "groupby": ["state", "gender", "name"],
  "metrics": [
    "sum__TotalAlerts"
  ]
}

Ensure that the metrics field contains valid metric expressions and that the groupby field contains valid column names.

If the issue persists, review the specific SQL query or expression causing the error and correct any syntax issues [1].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:connect:dynamodb sqllab Namespace | Anything related to the SQL Lab viz:charts Namespace | Anything related to viz types
Projects
None yet
Development

No branches or pull requests

3 participants
@rusackas @noahabbott123 and others