zabetak commented on a change in pull request #1164: [CALCITE-2998] RexCopier 
should support all rex types (Chunwei Lei)
URL: https://github.com/apache/calcite/pull/1164#discussion_r279147199
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java
 ##########
 @@ -44,13 +52,38 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
  * Test for {@link RexBuilder}.
  */
 public class RexBuilderTest {
 
+  private static final int PRECISION = 256;
+
+  /**
+   * MySqlTypeFactoryImpl provides a specific implementation of
+   * {@link SqlTypeFactoryImpl} which sets precision to 256 for VARCHAR.
+   */
+  private static class MySqlTypeFactoryImpl extends SqlTypeFactoryImpl {
+
+    MySqlTypeFactoryImpl(RelDataTypeSystem typeSystem) {
+      super(typeSystem);
+    }
+
+    @Override public RelDataType createTypeWithNullability(
+        final RelDataType type,
+        final boolean nullable) {
+      if (type.getSqlTypeName() == SqlTypeName.VARCHAR) {
 
 Review comment:
   A better way to do this would be to subclass `RelDataTypeSystemImpl` and 
override `getDefaultPrecision` method which is meant exactly for this.  Then 
you can simply instantiate SqlTypeFactoryImpl with the custom type system.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to