You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Danny Chen (Jira)" <ji...@apache.org> on 2019/11/01 06:20:00 UTC
[jira] [Updated] (CALCITE-3449) Sync the table name logic from
TableScan into the TableModify
[ https://issues.apache.org/jira/browse/CALCITE-3449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Danny Chen updated CALCITE-3449:
--------------------------------
Summary: Sync the table name logic from TableScan into the TableModify (was: Sync the table name logic from TableScan into the Tabl… …eModify)
> Sync the table name logic from TableScan into the TableModify
> -------------------------------------------------------------
>
> Key: CALCITE-3449
> URL: https://issues.apache.org/jira/browse/CALCITE-3449
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.21.0
> Reporter: Zhuang
> Assignee: Danny Chen
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.22.0
>
> Original Estimate: 12h
> Time Spent: 40m
> Remaining Estimate: 11h 20m
>
> When sending queries to target databse, sub schemas should be removed from the sql, but not for modify statement(update\delete\insert). For example,
> {quote}delete from "sub_schema".target_table where ...
> {quote}
> will send following sql to target database
> {quote}delete from {color:#ff0000}"sub_schema"{color}.target_table where ...
> {quote}
> But select quries worked as expect.
> {quote}select * from "sub_schema".target_table
> {quote}
> will be translated into following and send to target databse.
> {quote}select * from target_table
> {quote}
> I've done some inspect, and find that the code are different. In org.apache.calcite.rel.rel2sql.RelToSqlConverter.java, the table names have sub schemas in it.
>
> {code:title=RelToSqlConverter.java|borderStyle=solid}public Result visit(TableModify modify) {
> final Map<String, RelDataType> pairs = ImmutableMap.of();
> final Context context = aliasContext(pairs, false);
> // Target Table Name
> final SqlIdentifier sqlTargetTable =
> new SqlIdentifier(modify.getTable().getQualifiedName(), POS);
> {code}
> But in select query , the table name are just table name, without sub schema.
> {code:title=Bar.java|borderStyle=solid}
> public Result visit(TableScan e) {
> final SqlIdentifier identifier;
> final JdbcTable jdbcTable = e.getTable().unwrap(JdbcTable.class);
> if (jdbcTable != null) {
> // Use the foreign catalog, schema and table names, if they exist,
> // rather than the qualified name of the shadow table in Calcite.
> identifier = jdbcTable.tableName();
> } else {
> final List<String> qualifiedName = e.getTable().getQualifiedName();
> identifier = new SqlIdentifier(qualifiedName, SqlParserPos.ZERO);
> }
> {code}
> I'm really new to Caicite and commit issues, thanks!
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)