[
https://issues.apache.org/jira/browse/CALCITE-6195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17805212#comment-17805212
]
Alessandro Solimando edited comment on CALCITE-6195 at 1/10/24 4:19 PM:
------------------------------------------------------------------------
I think it's just a matter of finding the right combination of casing + quoting.
I suggest to try to write the same query with _sqline_ and use qualified names,
and see what works there, there is a good chance it will work even in your code
example, for instance:
{noformat}
final String postgresQuery = "select postgres.\"table1\".\"id\",
postgres.\"table1\".\"field1\", postgres.\"table2\".\"field1\" " +
"from postgres.\"table1\" join postgres.\"table2\" " +
" on postgres.\"table1\".\"id\" = postgres.\"table2\".\"id1\""
+
"where postgres.\"table1\".\"id\" < 5";{noformat}
Try also possibly to set relevant properties for quoting and casing, like in
the following (non-exhaustive) example:
{noformat}
final Properties info = new Properties();
info.setProperty("lex", "POSTGRES");
info.put(InternalProperty.CASE_SENSITIVE, true);
info.put(InternalProperty.UNQUOTED_CASING, Casing.TO_LOWER);
info.put(InternalProperty.QUOTED_CASING, Casing.UNCHANGED);{noformat}
was (Author: asolimando):
I think it's just a matter of finding the right combination of casing + quoting.
I suggest to try to write the same query with _sqline_ and use __ qualified
names, and see what works there, there is a good chance it will work even in
your code example, for instance:
{noformat}
final String postgresQuery = "select postgres.\"table1\".\"id\",
postgres.\"table1\".\"field1\", postgres.\"table2\".\"field1\" " +
"from postgres.\"table1\" join postgres.\"table2\" " +
" on postgres.\"table1\".\"id\" = postgres.\"table2\".\"id1\""
+
"where postgres.\"table1\".\"id\" < 5";{noformat}
Try also possibly to set relevant properties for quoting and casing, like in
the following (non-exhaustive) example:
{noformat}
final Properties info = new Properties();
info.setProperty("lex", "POSTGRES");
info.put(InternalProperty.CASE_SENSITIVE, true);
info.put(InternalProperty.UNQUOTED_CASING, Casing.TO_LOWER);
info.put(InternalProperty.QUOTED_CASING, Casing.UNCHANGED);{noformat}
> SqlValidator validateParameterizedExpression is not supporting qualified paths
> ------------------------------------------------------------------------------
>
> Key: CALCITE-6195
> URL: https://issues.apache.org/jira/browse/CALCITE-6195
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.36.0
> Reporter: David Dali Susanibar Arce
> Priority: Major
>
> The SQLValidator.validateParameterizedExpression method can be used to
> validate parameterized expressions.
> It is possible to register
> [validateParameterizedExpression|https://github.com/apache/calcite/blob/1b11d99e65d03a15ae4b25c47250b6918ce9aa10/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java#L11421:L11435]:
> {code:java}
> final Map<String, RelDataType> nameToTypeMap = new HashMap<>();
> nameToTypeMap.put("A", intType);
> nameToTypeMap.put("B", intTypeNull);
> final String expr = "a + b";
> final SqlNode validated = validator.validateParameterizedExpression(sqlNode,
> nameToTypeMap);{code}
>
> Problems appear if we are trying to register qualified paths:
> {code:java}
> final Map<String, RelDataType> nameToTypeMap = new HashMap<>();
> nameToTypeMap.put("EMP.A", intType);
> nameToTypeMap.put("EMP.B", intTypeNull);
> final String expr = "EMP.a + EMP.b";
> final SqlNode validated = validator.validateParameterizedExpression(sqlNode,
> nameToTypeMap);
> Error:
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 1 to
> line 1, column 3: Unknown identifier 'EMP'
> {code}
> I would appreciate if you could provide me with some advice regarding how to
> resolve this error.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)