Skip to content

Commit

Permalink
DRILL-2466: Fix "<a>.VARCHAR -> <b>.NVARCHAR" to "-> <b>.VARCHAR" (Ty…
Browse files Browse the repository at this point in the history
…pes.h).

- Fixed mapping from TypeProtos.MinorType.VARCHAR to java.sql.Types.NVARCHAR
  to be to java.sql.Types.VARCHAR.
- Also renamed getSqlType to getJdbcType, getSqlTypeName to getSqlTypeName.
  • Loading branch information
dsbos authored and parthchandra committed Mar 24, 2015
1 parent 64ad7a7 commit 544988f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions common/src/main/java/org/apache/drill/common/types/Types.java
Expand Up @@ -82,12 +82,15 @@ public static boolean isNumericType(MajorType type) {
}
}

public static int getSqlType(MajorType type) {
/***
* Gets JDBC type code for given Drill RPC-/protobuf-level type.
*/
public static int getJdbcType(MajorType type) {
if (type.getMode() == DataMode.REPEATED) {
return java.sql.Types.ARRAY;
}

switch(type.getMinorType()) {
switch (type.getMinorType()) {
case BIGINT:
return java.sql.Types.BIGINT;
case BIT:
Expand Down Expand Up @@ -146,9 +149,13 @@ public static int getSqlType(MajorType type) {
case VARBINARY:
return java.sql.Types.VARBINARY;
case VARCHAR:
return java.sql.Types.NVARCHAR;
return java.sql.Types.VARCHAR;
default:
throw new UnsupportedOperationException();
// TODO: This isn't really an unsupported-operation/-type case; this
// is an unexpected, code-out-of-sync-with-itself case, so use an
// exception intended for that.
throw new UnsupportedOperationException(
"Unexpected/unhandled " + type.getMinorType() + " value " + type.getMinorType() );
}
}

Expand Down
Expand Up @@ -82,11 +82,11 @@ public void updateColumnMetaData(String catalogName, String schemaName, String t
}

private static AvaticaType getAvaticaType(MajorType t){
int sqlTypeId = Types.getSqlType(t);
return ColumnMetaData.scalar(sqlTypeId, getSqlTypeName(sqlTypeId), Rep.BOOLEAN /* dummy value, unused */);
final int jdbcTypeId = Types.getJdbcType(t);
return ColumnMetaData.scalar(jdbcTypeId, getJdbcTypeName(jdbcTypeId), Rep.BOOLEAN /* dummy value, unused */);
}

private static String getSqlTypeName(int type) {
private static String getJdbcTypeName(int type) {
switch (type) {
case java.sql.Types.BIT:
return "BIT";
Expand Down

0 comments on commit 544988f

Please sign in to comment.