@@ -398,16 +398,7 @@ private SqlNode groupItem(List<SqlNode> groupKeys,
398
398
399
399
/** @see #dispatch */
400
400
public Result visit (TableScan e ) {
401
- final SqlIdentifier identifier ;
402
- final JdbcTable jdbcTable = e .getTable ().unwrap (JdbcTable .class );
403
- if (jdbcTable != null ) {
404
- // Use the foreign catalog, schema and table names, if they exist,
405
- // rather than the qualified name of the shadow table in Calcite.
406
- identifier = jdbcTable .tableName ();
407
- } else {
408
- final List <String > qualifiedName = e .getTable ().getQualifiedName ();
409
- identifier = new SqlIdentifier (qualifiedName , SqlParserPos .ZERO );
410
- }
401
+ final SqlIdentifier identifier = getSqlTargetTable (e );
411
402
return result (identifier , ImmutableList .of (Clause .FROM ), e , null );
412
403
}
413
404
@@ -652,14 +643,28 @@ public boolean hasTrickyRollup(Sort e, Aggregate aggregate) {
652
643
fc .getFieldIndex () < aggregate .getGroupSet ().cardinality ());
653
644
}
654
645
646
+ private SqlIdentifier getSqlTargetTable (RelNode e ) {
647
+ final SqlIdentifier sqlTargetTable ;
648
+ final JdbcTable jdbcTable = e .getTable ().unwrap (JdbcTable .class );
649
+ if (jdbcTable != null ) {
650
+ // Use the foreign catalog, schema and table names, if they exist,
651
+ // rather than the qualified name of the shadow table in Calcite.
652
+ sqlTargetTable = jdbcTable .tableName ();
653
+ } else {
654
+ final List <String > qualifiedName = e .getTable ().getQualifiedName ();
655
+ sqlTargetTable = new SqlIdentifier (qualifiedName , SqlParserPos .ZERO );
656
+ }
657
+
658
+ return sqlTargetTable ;
659
+ }
660
+
655
661
/** @see #dispatch */
656
662
public Result visit (TableModify modify ) {
657
663
final Map <String , RelDataType > pairs = ImmutableMap .of ();
658
664
final Context context = aliasContext (pairs , false );
659
665
660
666
// Target Table Name
661
- final SqlIdentifier sqlTargetTable =
662
- new SqlIdentifier (modify .getTable ().getQualifiedName (), POS );
667
+ final SqlIdentifier sqlTargetTable = getSqlTargetTable (modify );
663
668
664
669
switch (modify .getOperation ()) {
665
670
case INSERT : {
0 commit comments