}
}
public void testOracleTypeMapQuirks() throws SQLException {
MockResultSetMetadata mockResultSetMeta = new MockResultSetMetadata();
Dialect oracleDialect = new OracleDialect();
assertTrue(
"Oracle dialect NUMERIC type with 0 precision, 0 scale should map "
+ "to INT, unless column starts with 'm'",
oracleDialect.getType(
mockResultSetMeta.withColumnName("c0")
.withColumnType(Types.NUMERIC)
.withPrecision(0)
.withScale(0)
.build(),
0) == SqlStatement.Type.INT);
assertTrue(
"Oracle dialect NUMERIC type with non-zero precision, -127 scale "
+ " should map to DOUBLE. MONDRIAN-1044",
oracleDialect.getType(
mockResultSetMeta.withColumnName("c0")
.withColumnType(Types.NUMERIC)
.withPrecision(5)
.withScale(-127)
.build(),
0) == SqlStatement.Type.DOUBLE);
assertTrue(
"Oracle dialect NUMERIC type with precision less than 10, 0 scale "
+ " should map to INT. ",
oracleDialect.getType(
mockResultSetMeta.withColumnName("c0")
.withColumnType(Types.NUMERIC)
.withPrecision(9)
.withScale(0)
.build(),
0) == SqlStatement.Type.INT);
assertTrue(
"Oracle dialect NUMERIC type with precision = 38, scale = 0"
+ " should map to INT. 38 is a magic number in Oracle "
+ " for integers of unspecified precision.",
oracleDialect.getType(
mockResultSetMeta.withColumnName("c0")
.withColumnType(Types.NUMERIC)
.withPrecision(38)
.withScale(0)
.build(),
0) == SqlStatement.Type.INT);
assertTrue(
"Oracle dialect DECIMAL type with precision > 9, scale = 0"
+ " should map to DOUBLE (unless magic #38)",
oracleDialect.getType(
mockResultSetMeta.withColumnName("c0")
.withColumnType(Types.NUMERIC)
.withPrecision(20)
.withScale(0)
.build(),
0) == SqlStatement.Type.DOUBLE);
assertTrue(
"Oracle dialect NUMBER type with precision =0 , scale = -127"
+ " should map to INT. GROUPING SETS queries can shift"
+ " scale for columns to -127, whether INT or other NUMERIC."
+ " Assume INT unless the column name indicates it is a measure.",
oracleDialect.getType(
mockResultSetMeta.withColumnName("c0")
.withColumnType(Types.NUMERIC)
.withPrecision(0)
.withScale(-127)
.build(),
0) == SqlStatement.Type.INT);
assertTrue(
"Oracle dialect NUMBER type with precision =0 , scale = -127"
+ " should map to OBJECT if measure name starts with 'm'",
oracleDialect.getType(
mockResultSetMeta.withColumnName("m0")
.withColumnType(Types.NUMERIC)
.withPrecision(0)
.withScale(-127)
.build(),