This is an automated email from the ASF dual-hosted git repository.
zachjsh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 3f5f5921e0b Fix sql syntax error user (#16583)
3f5f5921e0b is described below
commit 3f5f5921e0ba798e07eadf61d26ceaf30a5bdccb
Author: zachjsh <[email protected]>
AuthorDate: Tue Jun 11 18:08:35 2024 -0400
Fix sql syntax error user (#16583)
This fixes an issue where in some cases, a SQL syntax error encountered
when parsing / planning a query results in an error returned to the user with
persona a `admin` when it should instead be `user`.
---
.../org/apache/druid/sql/calcite/planner/DruidPlanner.java | 8 +-------
.../org/apache/druid/sql/calcite/CalciteInsertDmlTest.java | 12 ++++++++++++
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git
a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
index 4b697a0d5df..cf1d22eb39b 100644
--- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
+++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
@@ -380,13 +380,7 @@ public class DruidPlanner implements Closeable
}
}
- return DruidException.forPersona(DruidException.Persona.DEVELOPER)
- .ofCategory(DruidException.Category.UNCATEGORIZED)
- .build(
- inner,
- "Unable to parse the SQL, unrecognized error
from calcite: [%s]",
- inner.getMessage()
- );
+ return InvalidSqlInput.exception(inner.getMessage());
}
catch (RelOptPlanner.CannotPlanException inner) {
return DruidException.forPersona(DruidException.Persona.USER)
diff --git
a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteInsertDmlTest.java
b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteInsertDmlTest.java
index bb9c03aa3c8..b40a4c87c3a 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteInsertDmlTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteInsertDmlTest.java
@@ -1626,6 +1626,18 @@ public class CalciteInsertDmlTest extends
CalciteIngestionDmlTest
.verify();
}
+ @Test
+ public void testInsertWithLongIdentifer()
+ {
+ // This test fails because an identifer is specified of length 200, which
exceeds the length limit of 128
+ // characters.
+ String longIdentifer = new String(new char[200]).replace('\0', 'a');
+ testIngestionQuery()
+ .sql(StringUtils.format("INSERT INTO t SELECT %s FROM foo PARTITIONED
BY ALL", longIdentifer)) // count is a keyword
+ .expectValidationError(invalidSqlContains(StringUtils.format("Length
of identifier '%s' must be less than or equal to 128 characters",
longIdentifer)))
+ .verify();
+ }
+
@Test
public void testInsertWithUnnamedColumnInSelectStatement()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]