Skip to content

A query in MSQ would issue wrong error code#14531

Merged
abhishekagarwal87 merged 2 commits intoapache:masterfrom
somu-imply:MSQ_error_code_issue
Jul 6, 2023
Merged

A query in MSQ would issue wrong error code#14531
abhishekagarwal87 merged 2 commits intoapache:masterfrom
somu-imply:MSQ_error_code_issue

Conversation

@somu-imply
Copy link
Copy Markdown
Contributor

@somu-imply somu-imply commented Jul 5, 2023

with a RuntimeException. Now the RuntimeException is being replaced by an user facing DruidException of Invalid category which would allow calcite not to throw an uncategorized exception.

For a query like

insert into test_talaria_test_extern_extern_cols 
select time_parse("time") as __time, * 
from table( 
extern(
'{"type": "s3", "uris": [\"s3://imply-eng-datasets/qa/IngestionTest/wikipedia/files/wikiticker-2015-09-12-sampled.mini.json.gz\"]}',
'{"type\": "json"}',
'[{"name": "time", "type": "string"}, {"name": "channel", "type": "string"}, {"countryName": "string"}]'
)
)
partitioned by DAY
clustered by channel

the query failed like

Error: druidException

Uncategorized calcite error message: [java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: `java.lang.NullPointerException` at [Source: (String)"[{"name": "time", "type": "string"}, {"name": "channel", "type": "string"}, {"countryName": "string"}]"; line: 1, column: 101] (through reference chain: java.util.ArrayList[2])]

After this change the expected behavior is

Error: druidException

Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: `java.lang.NullPointerException` at [Source: (String)"[{"name": "time", "type": "string"}, {"name": "channel", "type": "string"}, {"countryName": "string"}]"; line: 1, column: 101] (through reference chain: java.util.ArrayList[2])

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

…a RuntimeException. Now the RuntimeException is being replaced by an user facing DruidException of Invalid category which would allow calcite not to throw an uncategorized exception
@somu-imply somu-imply changed the title Msq error code issue A query in MSQ would issue wrong error code Jul 5, 2023
Comment on lines +124 to +126
throw DruidException.forPersona(DruidException.Persona.USER)
.ofCategory(DruidException.Category.INVALID_INPUT)
.build(e, e.getMessage());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this one specifically, just so you know, there is an InvalidInput.exception() that you can use. This makes it part of the "invalidInput" group of exceptions instead of the "general" group of exceptions.

"general"
)
.expectMessageContains(
"Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: `java.lang.NullPointerException`\n"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case specificaly, it would be great if the original NPE actually carried with it an indication of which field it expected to exist. That is, we likely need to get even deeper and make a better message for the NPE as well.

@AmatyaAvadhanula AmatyaAvadhanula added this to the 27.0 milestone Jul 19, 2023
sergioferragut pushed a commit to sergioferragut/druid that referenced this pull request Jul 21, 2023
with a RuntimeException. Now the RuntimeException is being replaced by an user facing DruidException of Invalid category which would allow calcite not to throw an uncategorized exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants