chunweilei 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_r279152055
########## 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: I am afraid it cannot work. The whole call stack is as follows: ``` RexCopier#copy => RelDataTypeFactoryImpl#copy => SqlTypeFactoryImpl#createTypeWithNullability => BasicSqlType#createWithNullability => new BasicSqlType(...) ``` You can see it does not use `getDefaultPrecision` in `RelDataTypeSystemImpl`. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services