boyjoy1127 commented on code in PR #23040:
URL: https://github.com/apache/shardingsphere/pull/23040#discussion_r1068119802


##########
kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/TranslatableTableScanExecutor.java:
##########
@@ -229,26 +327,47 @@ private RelNode createRelNode(final ShardingSphereTable 
table, final Translatabl
         RelOptCluster relOptCluster = 
RelOptCluster.create(SQLFederationPlannerUtil.createVolcanoPlanner(), new 
RexBuilder(JAVA_TYPE_FACTORY));
         RelBuilder builder = 
RelFactories.LOGICAL_BUILDER.create(relOptCluster, 
catalogReader).scan(table.getName());
         if (null != scanContext.getFilterValues()) {
-            builder.filter(createFilters(scanContext.getFilterValues()));
+            builder.filter(createFilters(scanContext.getFilterValues(), 
(SQLFederationDataContext) scanContext.getRoot()));
         }
         if (null != scanContext.getProjects()) {
             builder.project(createProjections(scanContext.getProjects(), 
builder, table.getColumnNames()));
         }
         return builder.build();
     }
     
-    private Collection<RexNode> createFilters(final String[] filterValues) {
+    private Collection<RexNode> createFilters(final String[] filterValues, 
final SQLFederationDataContext context) {
         Collection<RexNode> result = new LinkedList<>();
         JavaTypeFactory typeFactory = new 
JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
         RexBuilder rexBuilder = new RexBuilder(typeFactory);
         for (String each : filterValues) {
             if (!Strings.isNullOrEmpty(each)) {
-                result.add(StringToRexNodeUtil.buildRexNode(each, rexBuilder));
+                Map<Integer, Integer> columnMap = extractColumnMap(each);
+                String filterValue = extractFilterValue(each);
+                result.add(StringToRexNodeUtil.buildRexNode(filterValue, 
rexBuilder, context.getParameters(), columnMap));
             }
         }
         return result;
     }
     
+    private Map<Integer, Integer> extractColumnMap(final String 
filterExpression) {

Review Comment:
   Example as : "{1=4}"
   This means column 1 with type int, 4 represent int. According below:
   ```
   private Class getClass(final int dataType) {
           switch (dataType) {
               case -5:
                   return Long.class;
               case 4:
                   return Integer.class;
               case 6:
                   return Float.class;
               case 8:
                   return Double.class;
               case 1:
                   return String.class;
               case 12:
                   return String.class;
               case 91:
                   return Date.class;
               default:
                   return String.class;
           }
   ```
   
   
   
           public final static int BIT             =  -7;
   
           public final static int TINYINT         =  -6;
   
           public final static int SMALLINT        =   5;
   
           public final static int INTEGER         =   4;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>BIGINT</code>.
    */
           public final static int BIGINT          =  -5;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>FLOAT</code>.
    */
           public final static int FLOAT           =   6;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>REAL</code>.
    */
           public final static int REAL            =   7;
   
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>DOUBLE</code>.
    */
           public final static int DOUBLE          =   8;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>NUMERIC</code>.
    */
           public final static int NUMERIC         =   2;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>DECIMAL</code>.
    */
           public final static int DECIMAL         =   3;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>CHAR</code>.
    */
           public final static int CHAR            =   1;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>VARCHAR</code>.
    */
           public final static int VARCHAR         =  12;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>LONGVARCHAR</code>.
    */
           public final static int LONGVARCHAR     =  -1;
   
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>DATE</code>.
    */
           public final static int DATE            =  91;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>TIME</code>.
    */
           public final static int TIME            =  92;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>TIMESTAMP</code>.
    */
           public final static int TIMESTAMP       =  93;
   
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>BINARY</code>.
    */
           public final static int BINARY          =  -2;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>VARBINARY</code>.
    */
           public final static int VARBINARY       =  -3;
   
   /**
    * <P>The constant in the Java programming language, sometimes referred
    * to as a type code, that identifies the generic SQL type
    * <code>LONGVARBINARY</code>.
    */
           public final static int LONGVARBINARY   =  -4;
   
   /**
    * <P>The constant in the Java programming language
    * that identifies the generic SQL value
    * <code>NULL</code>.
    */
           public final static int NULL            =   0;
   
       /**
        * The constant in the Java programming language that indicates
        * that the SQL type is database-specific and
        * gets mapped to a Java object that can be accessed via
        * the methods <code>getObject</code> and <code>setObject</code>.
        */
           public final static int OTHER           = 1111;
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to