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`.
This commit is contained in:
zachjsh 2024-06-11 18:08:35 -04:00 committed by GitHub
parent fec48432d4
commit 3f5f5921e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -380,13 +380,7 @@ public class DruidPlanner implements Closeable
} }
} }
return DruidException.forPersona(DruidException.Persona.DEVELOPER) return InvalidSqlInput.exception(inner.getMessage());
.ofCategory(DruidException.Category.UNCATEGORIZED)
.build(
inner,
"Unable to parse the SQL, unrecognized error from calcite: [%s]",
inner.getMessage()
);
} }
catch (RelOptPlanner.CannotPlanException inner) { catch (RelOptPlanner.CannotPlanException inner) {
return DruidException.forPersona(DruidException.Persona.USER) return DruidException.forPersona(DruidException.Persona.USER)

View File

@ -1626,6 +1626,18 @@ public class CalciteInsertDmlTest extends CalciteIngestionDmlTest
.verify(); .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 @Test
public void testInsertWithUnnamedColumnInSelectStatement() public void testInsertWithUnnamedColumnInSelectStatement()
{ {