[
https://issues.apache.org/jira/browse/CALCITE-5076?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
galaxy yang updated CALCITE-5076:
---------------------------------
Component/s: core
Affects Version/s: 1.30.0
Description:
i have setted the CalciteConnectionConfig use the properties lex = MYSQL,
errors happen when i define the materializations use sql with mysql syntax, but
the query is ok
{code:java}
@Test void testScan() {
CalciteAssert.that()
.with(Lex.MYSQL)
.withMaterializations(
"{\n"
+ " version: '1.0',\n"
+ " defaultSchema: 'SCOTT_CLONE',\n"
+ " schemas: [ {\n"
+ " name: 'SCOTT_CLONE',\n"
+ " type: 'custom',\n"
+ " factory:
'org.apache.calcite.adapter.clone.CloneSchema$Factory',\n"
+ " operand: {\n"
+ " jdbcDriver: '" + JdbcTest.SCOTT.driver + "',\n"
+ " jdbcUser: '" + JdbcTest.SCOTT.username + "',\n"
+ " jdbcPassword: '" + JdbcTest.SCOTT.password + "',\n"
+ " jdbcUrl: '" + JdbcTest.SCOTT.url + "',\n"
+ " jdbcSchema: 'SCOTT'\n"
+ " } } ]\n"
+ "}",
"m0",
"select empno, deptno from `emp` order by deptno")
.query(
"select empno, deptno from `emp`")
.enableMaterializations(true)
.explainContains("EnumerableTableScan(table=[[SCOTT_CLONE, m0]])")
.sameResultWithMaterializationsDisabled();
}
{code}
it throws such error:
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Object 'emp'
not found within 'SCOTT_CLONE'; did you mean 'EMP'?
i setted the lex with Lex.MYSQL, but the materialization's sql seems only
support the default Lex.ORACLE, errors happen when i use back-quotes. but the
query sql is ok when i use mysql syntax.
it is not a graceful thing that the materialization's sql and query sql are two
different sql syntax when i changed the default syntax from oracle to others
was:
when i use org.apache.calcite.prepare.CalcitePrepareImpl#parse_ and
org.apache.calcite.prepare.CalcitePrepareImpl.CalcitePreparingStmt#expandView,
i noticed that in the two methods, the SqlParser uses the default
SqlParser.Config, not created from the context。
it causes that only default sql syntax can be parsed, i set the
CalciteConnectionConfig, but not effective.
can the SqlParser.Config created from the context, like the method
org.apache.calcite.prepare.CalcitePrepareImpl#prepare2_
!image-2022-03-31-23-46-46-939.png|width=615,height=267!
!image-2022-03-31-23-47-12-377.png|width=511,height=280!
Summary: errors happen when i define materializations use sql
with Lex.MYSQL (was: parserConfig is not set correct when use some methods
in CalcitePrepareImpl)
> errors happen when i define materializations use sql with Lex.MYSQL
> -------------------------------------------------------------------
>
> Key: CALCITE-5076
> URL: https://issues.apache.org/jira/browse/CALCITE-5076
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.30.0
> Reporter: galaxy yang
> Priority: Major
> Attachments: image-2022-03-31-23-44-44-916.png,
> image-2022-03-31-23-45-01-468.png, image-2022-03-31-23-45-33-979.png,
> image-2022-03-31-23-46-46-939.png, image-2022-03-31-23-47-12-377.png
>
>
> i have setted the CalciteConnectionConfig use the properties lex = MYSQL,
> errors happen when i define the materializations use sql with mysql syntax,
> but the query is ok
> {code:java}
> @Test void testScan() {
> CalciteAssert.that()
> .with(Lex.MYSQL)
> .withMaterializations(
> "{\n"
> + " version: '1.0',\n"
> + " defaultSchema: 'SCOTT_CLONE',\n"
> + " schemas: [ {\n"
> + " name: 'SCOTT_CLONE',\n"
> + " type: 'custom',\n"
> + " factory:
> 'org.apache.calcite.adapter.clone.CloneSchema$Factory',\n"
> + " operand: {\n"
> + " jdbcDriver: '" + JdbcTest.SCOTT.driver + "',\n"
> + " jdbcUser: '" + JdbcTest.SCOTT.username + "',\n"
> + " jdbcPassword: '" + JdbcTest.SCOTT.password + "',\n"
> + " jdbcUrl: '" + JdbcTest.SCOTT.url + "',\n"
> + " jdbcSchema: 'SCOTT'\n"
> + " } } ]\n"
> + "}",
> "m0",
> "select empno, deptno from `emp` order by deptno")
> .query(
> "select empno, deptno from `emp`")
> .enableMaterializations(true)
> .explainContains("EnumerableTableScan(table=[[SCOTT_CLONE, m0]])")
> .sameResultWithMaterializationsDisabled();
> }
> {code}
> it throws such error:
> Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Object
> 'emp' not found within 'SCOTT_CLONE'; did you mean 'EMP'?
> i setted the lex with Lex.MYSQL, but the materialization's sql seems only
> support the default Lex.ORACLE, errors happen when i use back-quotes. but
> the query sql is ok when i use mysql syntax.
> it is not a graceful thing that the materialization's sql and query sql are
> two different sql syntax when i changed the default syntax from oracle to
> others
--
This message was sent by Atlassian Jira
(v8.20.1#820001)