/** * Parses a COLLATE clause */ final public SqlCollation CollateClause() throws ParseException { jj_consume_token(COLLATE); jj_consume_token(COLLATION_ID); {if (true) return new SqlCollation( getToken(0).image, SqlCollation.Coercibility.EXPLICIT);} throw new Error("Missing return statement in function"); }
@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) }; } }
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; }
assert null != col1; assert null != col2; final Coercibility coercibility1 = col1.getCoercibility(); final Coercibility coercibility2 = col2.getCoercibility(); switch (coercibility1) { case COERCIBLE: switch (coercibility2) { case COERCIBLE: return new SqlCollation( col2.collationName, Coercibility.COERCIBLE); case IMPLICIT: return new SqlCollation( col2.collationName, Coercibility.IMPLICIT); return null; case EXPLICIT: return new SqlCollation( col2.collationName, Coercibility.EXPLICIT); switch (coercibility2) { case COERCIBLE: return new SqlCollation( col1.collationName, Coercibility.IMPLICIT); case IMPLICIT: if (col1.collationName.equals(col2.collationName)) {
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 static void checkCharsetAndCollateConsistentIfCharType( RelDataType type) { // (every charset must have a default collation) if (SqlTypeUtil.inCharFamily(type)) { Charset strCharset = type.getCharset(); Charset colCharset = type.getCollation().getCharset(); assert null != strCharset; assert null != colCharset; if (!strCharset.equals(colCharset)) { if (false) { // todo: enable this checking when we have a charset to // collation mapping throw new Error(type.toString() + " was found to have charset '" + strCharset.name() + "' and a mismatched collation charset '" + colCharset.name() + "'"); } } } }
/** * Returns the collating sequence (the collation name) and the coercibility * for the resulting value of a dyadic operator. * * @param col1 first operand for the dyadic operation * @param col2 second operand for the dyadic operation * @return the resulting collation sequence. The "no collating sequence" * result is returned as null. * * @see Glossary#SQL99 SQL:1999 Part 2 Section 4.2.3 Table 2 */ public static SqlCollation getCoercibilityDyadicOperator( SqlCollation col1, SqlCollation col2) { return getCoercibilityDyadic(col1, col2); }
|| arg.collation.equals(collation))) { throw new IllegalArgumentException("mismatched collations");
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; }
assert null != col1; assert null != col2; final Coercibility coercibility1 = col1.getCoercibility(); final Coercibility coercibility2 = col2.getCoercibility(); switch (coercibility1) { case COERCIBLE: switch (coercibility2) { case COERCIBLE: return new SqlCollation( col2.collationName, Coercibility.COERCIBLE); case IMPLICIT: return new SqlCollation( col2.collationName, Coercibility.IMPLICIT); return null; case EXPLICIT: return new SqlCollation( col2.collationName, Coercibility.EXPLICIT); switch (coercibility2) { case COERCIBLE: return new SqlCollation( col1.collationName, Coercibility.IMPLICIT); case IMPLICIT: if (col1.collationName.equals(col2.collationName)) {
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 static void checkCharsetAndCollateConsistentIfCharType( RelDataType type) { // (every charset must have a default collation) if (SqlTypeUtil.inCharFamily(type)) { Charset strCharset = type.getCharset(); Charset colCharset = type.getCollation().getCharset(); assert null != strCharset; assert null != colCharset; if (!strCharset.equals(colCharset)) { if (false) { // todo: enable this checking when we have a charset to // collation mapping throw new Error(type.toString() + " was found to have charset '" + strCharset.name() + "' and a mismatched collation charset '" + colCharset.name() + "'"); } } } }
/** * Returns the collating sequence (the collation name) and the coercibility * for the resulting value of a dyadic operator. * * @param col1 first operand for the dyadic operation * @param col2 second operand for the dyadic operation * @return the resulting collation sequence. The "no collating sequence" * result is returned as null. * * @see Glossary#SQL99 SQL:1999 Part 2 Section 4.2.3 Table 2 */ public static SqlCollation getCoercibilityDyadicOperator( SqlCollation col1, SqlCollation col2) { return getCoercibilityDyadic(col1, col2); }
|| arg.collation.equals(collation))) { throw new IllegalArgumentException("mismatched collations");
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; }
/** * Parses a COLLATE clause */ final public SqlCollation CollateClause() throws ParseException { jj_consume_token(COLLATE); jj_consume_token(COLLATION_ID); {if (true) return new SqlCollation( getToken(0).image, SqlCollation.Coercibility.EXPLICIT);} throw new Error("Missing return statement in function"); }
sb.append(collation.getCollationName()); sb.append("\"");
throw new AssertionError("RelDataType object should have been assigned " + "a (default) collation when calling deriveType"); } else if (!t0.getCollation().getCharset().equals( t1.getCollation().getCharset())) { return false;
/** * Returns the collating sequence (the collation name) and the coercibility * for the resulting value of a dyadic operator. * * @param col1 first operand for the dyadic operation * @param col2 second operand for the dyadic operation * @return the resulting collation sequence * * @throws org.apache.calcite.runtime.CalciteException from * {@link org.apache.calcite.runtime.CalciteResource#invalidCompare} or * {@link org.apache.calcite.runtime.CalciteResource#differentCollations} * if no collating sequence can be deduced * * @see Glossary#SQL99 SQL:1999 Part 2 Section 4.2.3 Table 2 */ public static SqlCollation getCoercibilityDyadicOperatorThrows( SqlCollation col1, SqlCollation col2) { SqlCollation ret = getCoercibilityDyadic(col1, col2); if (null == ret) { throw RESOURCE.invalidCompare( col1.collationName, "" + col1.coercibility, col2.collationName, "" + col2.coercibility).ex(); } return ret; }
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; }