CatalogUtil { public static boolean isCompatibleType(final Type definedType, final Type givenType) { if (givenType.getNumber() > definedType.getNumber()) { return false; } boolean flag = definedType == givenType; flag |= givenType == Type.NULL_TYPE; flag |= definedType == Type.ANY; if (flag) { return true; } Type actualType = definedType; if (CatalogUtil.isArrayType(definedType)) { actualType = CatalogUtil.getPrimitiveTypeOf(definedType); } flag |= DataTypeUtil.isUpperCastable(actualType, givenType); return flag; }  static String normalizeIdentifier(String identifier); static String normalizeIdentifierPart(String part); static String denormalizeIdentifier(String identifier); static String denormalizePart(String identifier); static boolean isShouldBeQuoted(String columnName); static String stripQuote(String str); static boolean isDelimited(String identifier); static boolean isSimpleIdentifier(String columnOrTableName); static boolean isFQColumnName(String tableName); static boolean isFQTableName(String tableName); static String [] splitFQTableName(String qualifiedName); static String [] splitTableName(String tableName); static String buildFQName(String... identifiers); static String extractQualifier(String name); static String extractSimpleName(String name); static String getCanonicalTableName(String databaseName, String tableName); static String getStoreTypeString(final StoreType type); static StoreType getStoreType(final String typeStr); static TableMeta newTableMeta(String storeType); static TableMeta newTableMeta(String storeType, KeyValueSet options); static TableDesc newTableDesc(String tableName, Schema schema, TableMeta meta, Path path); static TableDesc newTableDesc(TableDescProto proto); static PartitionMethodDesc newPartitionMethodDesc(CatalogProtos.PartitionMethodProto proto); static SchemaProto getQualfiedSchema(String tableName, SchemaProto schema); static DataType newDataType(Type type, String code); static DataType newDataType(Type type, String code, int len); static DataType newSimpleDataType(Type type); static DataType newRecordType(int nestedFieldNum); static DataType [] newSimpleDataTypeArray(Type... types); static DataType newDataTypeWithLen(Type type, int length); static String columnToDDLString(Column column); static boolean isArrayType(TajoDataTypes.Type type); static boolean isMatchedFunction(List<DataType> definedTypes, List<DataType> givenTypes); static boolean checkIfMatchedNonVarLengthFunction(List<DataType> definedTypes, List<DataType> givenTypes,
                                                           int n, boolean lastArrayCompatible); static boolean checkIfCompatibleIncludingArray(Type defined, Type given); static boolean checkIfVariableLengthParamDefinition(List<DataType> definedTypes); static Type getPrimitiveTypeOf(Type type); static boolean isCompatibleType(final Type definedType, final Type givenType); static DataType getWidestType(DataType...types); static CatalogProtos.TableIdentifierProto buildTableIdentifier(String databaseName, String tableName); static void closeQuietly(Connection conn); static void closeQuietly(Statement stmt); static void closeQuietly(ResultSet res); static void closeQuietly(Statement stmt, ResultSet res); static AlterTableDesc renameColumn(String tableName, String oldColumName, String newColumName,
                                            AlterTableType alterTableType); static AlterTableDesc renameTable(String tableName, String newTableName, AlterTableType alterTableType); static AlterTableDesc addNewColumn(String tableName, Column column, AlterTableType alterTableType); static AlterTableDesc setProperty(String tableName, KeyValueSet params, AlterTableType alterTableType); static KeyValueSet newPhysicalProperties(String storeType); static final String TEXTFILE_NAME; static final Set<String> RESERVED_KEYWORDS_SET; static final Map<Type, Map<Type, Type>> OPERATION_CASTING_MAP; static final String BLOCK_SIZE; static final String PAGE_SIZE; static final String COMPRESSION; static final String ENABLE_DICTIONARY; static final String VALIDATION; }
@Test public final void testIsCompatibleType() { assertFalse(CatalogUtil.isCompatibleType(Type.INT4, Type.INT8)); assertTrue(CatalogUtil.isCompatibleType(Type.INT8, Type.INT4)); assertFalse(CatalogUtil.isCompatibleType(Type.FLOAT4, Type.FLOAT8)); assertTrue(CatalogUtil.isCompatibleType(Type.FLOAT8, Type.FLOAT4)); assertTrue(CatalogUtil.isCompatibleType(Type.FLOAT8, Type.INT4)); assertFalse(CatalogUtil.isCompatibleType(Type.FLOAT8_ARRAY, Type.TEXT_ARRAY)); assertFalse(CatalogUtil.isCompatibleType(Type.TEXT_ARRAY, Type.FLOAT8_ARRAY)); }