@Override public Object[] apply(final RelDataTypeField field) { final RelDataType type = field.getType(); boolean isNumeric = SqlTypeName.NUMERIC_TYPES.contains(type.getSqlTypeName()); boolean isCharacter = SqlTypeName.CHAR_TYPES.contains(type.getSqlTypeName()); boolean isDateTime = SqlTypeName.DATETIME_TYPES.contains(type.getSqlTypeName()); return new Object[]{ CATALOG_NAME, // TABLE_CATALOG schemaName, // TABLE_SCHEMA tableName, // TABLE_NAME field.getName(), // COLUMN_NAME String.valueOf(field.getIndex()), // ORDINAL_POSITION "", // COLUMN_DEFAULT type.isNullable() ? "YES" : "NO", // IS_NULLABLE type.getSqlTypeName().toString(), // DATA_TYPE null, // CHARACTER_MAXIMUM_LENGTH null, // CHARACTER_OCTET_LENGTH isNumeric ? String.valueOf(type.getPrecision()) : null, // NUMERIC_PRECISION isNumeric ? "10" : null, // NUMERIC_PRECISION_RADIX isNumeric ? String.valueOf(type.getScale()) : null, // NUMERIC_SCALE isDateTime ? String.valueOf(type.getPrecision()) : null, // DATETIME_PRECISION isCharacter ? type.getCharset().name() : null, // CHARACTER_SET_NAME isCharacter ? type.getCollation().getCollationName() : null, // COLLATION_NAME Long.valueOf(type.getSqlTypeName().getJdbcOrdinal()) // JDBC_TYPE (Druid extension) }; } }
sb.append(collation.getCollationName()); sb.append("\"");
sb.append(collation.getCollationName()); sb.append("\"");
@Override public Object[] apply(final RelDataTypeField field) { final RelDataType type = field.getType(); boolean isNumeric = SqlTypeName.NUMERIC_TYPES.contains(type.getSqlTypeName()); boolean isCharacter = SqlTypeName.CHAR_TYPES.contains(type.getSqlTypeName()); boolean isDateTime = SqlTypeName.DATETIME_TYPES.contains(type.getSqlTypeName()); return new Object[]{ EMPTY_CATALOG, // TABLE_CATALOG schemaName, // TABLE_SCHEMA tableName, // TABLE_NAME field.getName(), // COLUMN_NAME String.valueOf(field.getIndex()), // ORDINAL_POSITION "", // COLUMN_DEFAULT type.isNullable() ? "YES" : "NO", // IS_NULLABLE type.getSqlTypeName().toString(), // DATA_TYPE null, // CHARACTER_MAXIMUM_LENGTH null, // CHARACTER_OCTET_LENGTH isNumeric ? String.valueOf(type.getPrecision()) : null, // NUMERIC_PRECISION isNumeric ? "10" : null, // NUMERIC_PRECISION_RADIX isNumeric ? String.valueOf(type.getScale()) : null, // NUMERIC_SCALE isDateTime ? String.valueOf(type.getPrecision()) : null, // DATETIME_PRECISION isCharacter ? type.getCharset().name() : null, // CHARACTER_SET_NAME isCharacter ? type.getCollation().getCollationName() : null, // COLLATION_NAME Long.valueOf(type.getSqlTypeName().getJdbcOrdinal()) // JDBC_TYPE (Druid extension) }; } }
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operand(0)); if (null == operandType) { throw new AssertionError("operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operand(0)); if (null == operandType) { throw new AssertionError("operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operand(0)); if (null == operandType) { throw new AssertionError("operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }
protected RelDataType adjustType( SqlValidator validator, SqlCall call, RelDataType type) { if (SqlTypeUtil.inCharFamily(type)) { // Determine coercibility and resulting collation name of // unary operator if needed. RelDataType operandType = validator.getValidatedNodeType(call.operand(0)); if (null == operandType) { throw new AssertionError("operand's type should have been derived"); } if (SqlTypeUtil.inCharFamily(operandType)) { SqlCollation collation = operandType.getCollation(); assert null != collation : "An implicit or explicit collation should have been set"; type = validator.getTypeFactory() .createTypeWithCharsetAndCollation( type, type.getCharset(), new SqlCollation( collation.getCollationName(), collation.getCoercibility())); } } return type; }
public void checkCollation( String expression, String expectedCollationName, SqlCollation.Coercibility expectedCoercibility) { for (String sql : buildQueries(expression)) { RelDataType actualType = getColumnType(sql); SqlCollation collation = actualType.getCollation(); assertEquals( expectedCollationName, collation.getCollationName()); assertEquals(expectedCoercibility, collation.getCoercibility()); } }
public void checkCollation( String expression, String expectedCollationName, SqlCollation.Coercibility expectedCoercibility) { for (String sql : buildQueries(expression)) { RelDataType actualType = getColumnType(sql); SqlCollation collation = actualType.getCollation(); assertEquals( expectedCollationName, collation.getCollationName()); assertEquals(expectedCoercibility, collation.getCoercibility()); } }