@Override public int getMaxPrecision(final SqlTypeName typeName) { return RelDataTypeSystem.DEFAULT.getMaxPrecision(typeName); }
final int fracPrecision = qualifier.getFractionalSecondPrecision(typeSystem); final int maxPrecision = typeSystem.getMaxPrecision(qualifier.typeName()); final int minPrecision = qualifier.typeName().getMinPrecision(); final int minScale = qualifier.typeName().getMinScale();
@Override public int getMaxPrecision(final SqlTypeName typeName) { return RelDataTypeSystem.DEFAULT.getMaxPrecision(typeName); }
public int getMaxPrecision(SqlTypeName typeName) { return typeSystem.getMaxPrecision(typeName); }
public int getMaxPrecision(SqlTypeName typeName) { return typeSystem.getMaxPrecision(typeName); }
public RelDataType createSqlType( SqlTypeName typeName, int precision, int scale) { assertBasic(typeName); assert (precision >= 0) || (precision == RelDataType.PRECISION_NOT_SPECIFIED); final int maxPrecision = typeSystem.getMaxPrecision(typeName); if (maxPrecision >= 0 && precision > maxPrecision) { precision = maxPrecision; } RelDataType newType = new BasicSqlType(typeSystem, typeName, precision, scale); newType = SqlTypeUtil.addCharsetAndCollation(newType, this); return canonize(newType); }
public RelDataType createSqlType( SqlTypeName typeName, int precision, int scale) { assertBasic(typeName); assert (precision >= 0) || (precision == RelDataType.PRECISION_NOT_SPECIFIED); final int maxPrecision = typeSystem.getMaxPrecision(typeName); if (maxPrecision >= 0 && precision > maxPrecision) { precision = maxPrecision; } RelDataType newType = new BasicSqlType(typeSystem, typeName, precision, scale); newType = SqlTypeUtil.addCharsetAndCollation(newType, this); return canonize(newType); }
private ImmutableList<MetaTypeInfo> getAllDefaultType() { final ImmutableList.Builder<MetaTypeInfo> allTypeList = ImmutableList.builder(); final CalciteConnectionImpl conn = (CalciteConnectionImpl) connection; final RelDataTypeSystem typeSystem = conn.typeFactory.getTypeSystem(); for (SqlTypeName sqlTypeName : SqlTypeName.values()) { allTypeList.add( new MetaTypeInfo(sqlTypeName.getName(), sqlTypeName.getJdbcOrdinal(), typeSystem.getMaxPrecision(sqlTypeName), typeSystem.getLiteral(sqlTypeName, true), typeSystem.getLiteral(sqlTypeName, false), // All types are nullable (short) DatabaseMetaData.typeNullable, typeSystem.isCaseSensitive(sqlTypeName), // Making all type searchable; we may want to // be specific and declare under SqlTypeName (short) DatabaseMetaData.typeSearchable, false, false, typeSystem.isAutoincrement(sqlTypeName), (short) sqlTypeName.getMinScale(), (short) typeSystem.getMaxScale(sqlTypeName), typeSystem.getNumTypeRadix(sqlTypeName))); } return allTypeList.build(); }
private ImmutableList<MetaTypeInfo> getAllDefaultType() { final ImmutableList.Builder<MetaTypeInfo> allTypeList = ImmutableList.builder(); final CalciteConnectionImpl conn = (CalciteConnectionImpl) connection; final RelDataTypeSystem typeSystem = conn.typeFactory.getTypeSystem(); for (SqlTypeName sqlTypeName : SqlTypeName.values()) { allTypeList.add( new MetaTypeInfo(sqlTypeName.getName(), sqlTypeName.getJdbcOrdinal(), typeSystem.getMaxPrecision(sqlTypeName), typeSystem.getLiteral(sqlTypeName, true), typeSystem.getLiteral(sqlTypeName, false), // All types are nullable (short) DatabaseMetaData.typeNullable, typeSystem.isCaseSensitive(sqlTypeName), // Making all type searchable; we may want to // be specific and declare under SqlTypeName (short) DatabaseMetaData.typeSearchable, false, false, typeSystem.isAutoincrement(sqlTypeName), (short) sqlTypeName.getMinScale(), (short) typeSystem.getMaxScale(sqlTypeName), typeSystem.getNumTypeRadix(sqlTypeName))); } return allTypeList.build(); }
public RelDataType createSqlType( SqlTypeName typeName, int precision) { final int maxPrecision = typeSystem.getMaxPrecision(typeName); if (maxPrecision >= 0 && precision > maxPrecision) { precision = maxPrecision; } if (typeName.allowsScale()) { return createSqlType(typeName, precision, typeName.getDefaultScale()); } assertBasic(typeName); assert (precision >= 0) || (precision == RelDataType.PRECISION_NOT_SPECIFIED); RelDataType newType = new BasicSqlType(typeSystem, typeName, precision); newType = SqlTypeUtil.addCharsetAndCollation(newType, this); return canonize(newType); }
public RelDataType createSqlType( SqlTypeName typeName, int precision) { final int maxPrecision = typeSystem.getMaxPrecision(typeName); if (maxPrecision >= 0 && precision > maxPrecision) { precision = maxPrecision; } if (typeName.allowsScale()) { return createSqlType(typeName, precision, typeName.getDefaultScale()); } assertBasic(typeName); assert (precision >= 0) || (precision == RelDataType.PRECISION_NOT_SPECIFIED); RelDataType newType = new BasicSqlType(typeSystem, typeName, precision); newType = SqlTypeUtil.addCharsetAndCollation(newType, this); return canonize(newType); }
private ImmutableList<MetaTypeInfo> getAllDefaultType() { final ImmutableList.Builder<MetaTypeInfo> allTypeList = new ImmutableList.Builder<>(); final RelDataTypeSystem typeSystem = getConnection().getTypeFactory().getTypeSystem(); for (SqlTypeName sqlTypeName : SqlTypeName.values()) { allTypeList.add( new MetaTypeInfo(sqlTypeName.getName(), sqlTypeName.getJdbcOrdinal(), typeSystem.getMaxPrecision(sqlTypeName), typeSystem.getLiteral(sqlTypeName, true), typeSystem.getLiteral(sqlTypeName, false), // All types are nullable (short) DatabaseMetaData.typeNullable, typeSystem.isCaseSensitive(sqlTypeName), // Making all type searchable; we may want to // be specific and declare under SqlTypeName (short) DatabaseMetaData.typeSearchable, false, false, typeSystem.isAutoincrement(sqlTypeName), (short) sqlTypeName.getMinScale(), (short) typeSystem.getMaxScale(sqlTypeName), typeSystem.getNumTypeRadix(sqlTypeName))); } return allTypeList.build(); }
public SqlNode getCastSpec(RelDataType type) { if (type instanceof BasicSqlType) { int precision = type.getPrecision(); switch (type.getSqlTypeName()) { case VARCHAR: // if needed, adjust varchar length to max length supported by the system int maxPrecision = getTypeSystem().getMaxPrecision(type.getSqlTypeName()); if (type.getPrecision() > maxPrecision) { precision = maxPrecision; } } return new SqlDataTypeSpec( new SqlIdentifier(type.getSqlTypeName().name(), SqlParserPos.ZERO), precision, type.getScale(), type.getCharset() != null && supportsCharSet() ? type.getCharset().name() : null, null, SqlParserPos.ZERO); } return SqlTypeUtil.convertTypeToSpec(type); }
@Test public void testTimestampAddFractionalSeconds() { tester.setFor(SqlStdOperatorTable.TIMESTAMP_ADD); tester.checkType( "timestampadd(SQL_TSI_FRAC_SECOND, 2, timestamp '2016-02-24 12:42:25.000000')", // "2016-02-24 12:42:25.000002", "TIMESTAMP(3) NOT NULL"); // The following test would correctly return "TIMESTAMP(6) NOT NULL" if max // precision were 6 or higher assumeTrue(tester.getValidator().getTypeFactory().getTypeSystem() .getMaxPrecision(SqlTypeName.TIMESTAMP) == 3); tester.checkType( "timestampadd(MICROSECOND, 2, timestamp '2016-02-24 12:42:25.000000')", // "2016-02-24 12:42:25.000002", "TIMESTAMP(3) NOT NULL"); }
@Test public void testTimestampAddFractionalSeconds() { tester.setFor(SqlStdOperatorTable.TIMESTAMP_ADD); tester.checkType( "timestampadd(SQL_TSI_FRAC_SECOND, 2, timestamp '2016-02-24 12:42:25.000000')", // "2016-02-24 12:42:25.000002", "TIMESTAMP(3) NOT NULL"); // The following test would correctly return "TIMESTAMP(6) NOT NULL" if max // precision were 6 or higher assumeTrue(tester.getValidator().getTypeFactory().getTypeSystem() .getMaxPrecision(SqlTypeName.TIMESTAMP) == 3); tester.checkType( "timestampadd(MICROSECOND, 2, timestamp '2016-02-24 12:42:25.000000')", // "2016-02-24 12:42:25.000002", "TIMESTAMP(3) NOT NULL"); }
final int fracPrecision = qualifier.getFractionalSecondPrecision(typeSystem); final int maxPrecision = typeSystem.getMaxPrecision(qualifier.typeName()); final int minPrecision = qualifier.typeName().getMinPrecision(); final int minScale = qualifier.typeName().getMinScale();
final int fracPrecision = qualifier.getFractionalSecondPrecision(typeSystem); final int maxPrecision = typeSystem.getMaxPrecision(qualifier.typeName()); final int minPrecision = qualifier.typeName().getMinPrecision(); final int minScale = qualifier.typeName().getMinScale();
/** Returns a list of typical types. */ public static List<RelDataType> getTypes(RelDataTypeFactory typeFactory) { final int maxPrecision = typeFactory.getTypeSystem().getMaxPrecision(SqlTypeName.DECIMAL); return ImmutableList.of( typeFactory.createSqlType(SqlTypeName.BOOLEAN), typeFactory.createSqlType(SqlTypeName.TINYINT), typeFactory.createSqlType(SqlTypeName.SMALLINT), typeFactory.createSqlType(SqlTypeName.INTEGER), typeFactory.createSqlType(SqlTypeName.BIGINT), typeFactory.createSqlType(SqlTypeName.DECIMAL), typeFactory.createSqlType(SqlTypeName.DECIMAL, 5), typeFactory.createSqlType(SqlTypeName.DECIMAL, 6, 2), typeFactory.createSqlType(SqlTypeName.DECIMAL, maxPrecision, 0), typeFactory.createSqlType(SqlTypeName.DECIMAL, maxPrecision, 5), // todo: test IntervalDayTime and IntervalYearMonth // todo: test Float, Real, Double typeFactory.createSqlType(SqlTypeName.CHAR, 5), typeFactory.createSqlType(SqlTypeName.VARCHAR, 1), typeFactory.createSqlType(SqlTypeName.VARCHAR, 20), typeFactory.createSqlType(SqlTypeName.BINARY, 3), typeFactory.createSqlType(SqlTypeName.VARBINARY, 4), typeFactory.createSqlType(SqlTypeName.DATE), typeFactory.createSqlType(SqlTypeName.TIME, 0), typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 0)); }
/** Returns a list of typical types. */ public static List<RelDataType> getTypes(RelDataTypeFactory typeFactory) { final int maxPrecision = typeFactory.getTypeSystem().getMaxPrecision(SqlTypeName.DECIMAL); return ImmutableList.of( typeFactory.createSqlType(SqlTypeName.BOOLEAN), typeFactory.createSqlType(SqlTypeName.TINYINT), typeFactory.createSqlType(SqlTypeName.SMALLINT), typeFactory.createSqlType(SqlTypeName.INTEGER), typeFactory.createSqlType(SqlTypeName.BIGINT), typeFactory.createSqlType(SqlTypeName.DECIMAL), typeFactory.createSqlType(SqlTypeName.DECIMAL, 5), typeFactory.createSqlType(SqlTypeName.DECIMAL, 6, 2), typeFactory.createSqlType(SqlTypeName.DECIMAL, maxPrecision, 0), typeFactory.createSqlType(SqlTypeName.DECIMAL, maxPrecision, 5), // todo: test IntervalDayTime and IntervalYearMonth // todo: test Float, Real, Double typeFactory.createSqlType(SqlTypeName.CHAR, 5), typeFactory.createSqlType(SqlTypeName.VARCHAR, 1), typeFactory.createSqlType(SqlTypeName.VARCHAR, 20), typeFactory.createSqlType(SqlTypeName.BINARY, 3), typeFactory.createSqlType(SqlTypeName.VARBINARY, 4), typeFactory.createSqlType(SqlTypeName.DATE), typeFactory.createSqlType(SqlTypeName.TIME, 0), typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 0)); }
for (SqlTypeName typeName : SqlTypeName.INTERVAL_TYPES) { assertThat(typeName.getMinPrecision(), is(1)); assertThat(typeSystem.getMaxPrecision(typeName), is(10)); assertThat(typeSystem.getDefaultPrecision(typeName), is(2)); assertThat(typeName.getMinScale(), is(1));