Skip to content

Commit

Permalink
#240: added hashtype support (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSergienko authored Oct 17, 2019
1 parent b71b2b3 commit 593dcfc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jdbc-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<junit.version>5.4.2</junit.version>
<junit.platform.version>1.4.2</junit.platform.version>
<maven.surefire.version>2.22.1</maven.surefire.version>
<vscommon.version>7.3.0</vscommon.version>
<vscommon.version>7.4.0</vscommon.version>
</properties>
<distributionManagement>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ExasolColumnMetadataReader extends BaseColumnMetadataReader {
static final int EXASOL_INTERVAL_YEAR_TO_MONTHS = -103;
static final int EXASOL_GEOMETRY = 123;
static final int EXASOL_TIMESTAMP = 124;
static final int EXASOL_HASHTYPE = 125;
private static final int DEFAULT_HASHTYPE_BYTESIZE = 16;
private static final int DEFAULT_INTERVAL_DAY_TO_SECOND_FRACTION = 3;
private static final int DEFAULT_INTERVAL_DAY_TO_SECOND_PRECISION = 2;
private static final int DEFAULT_INTERVAL_YEAR_TO_MONTH_PRECISION = 2;
Expand Down Expand Up @@ -45,6 +47,8 @@ public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
return DataType.createGeometry(DEFAULT_SPACIAL_REFERENCE_SYSTEM_IDENTIFIER);
case EXASOL_TIMESTAMP:
return DataType.createTimestamp(true);
case EXASOL_HASHTYPE:
return DataType.createHashtype(DEFAULT_HASHTYPE_BYTESIZE);
default:
return super.mapJdbcType(jdbcTypeDescription);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
case Types.NVARCHAR:
case Types.LONGVARCHAR:
case Types.LONGNVARCHAR:
return convertVarChar(jdbcTypeDescription.getPrecisionOrSize(), jdbcTypeDescription.getCharOctetLength());
return convertVarChar(jdbcTypeDescription.getPrecisionOrSize(), jdbcTypeDescription.getByteSize());
case Types.CHAR:
case Types.NCHAR:
return convertChar(jdbcTypeDescription.getPrecisionOrSize(), jdbcTypeDescription.getCharOctetLength());
return convertChar(jdbcTypeDescription.getPrecisionOrSize(), jdbcTypeDescription.getByteSize());
case Types.DATE:
return DataType.createDate();
case Types.TIMESTAMP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class JdbcTypeDescription {
private final int jdbcType;
private final int decimalScale;
private final int precisionOrSize;
private final int charOctetLength;
private final int byteSize;
private final String typeName;

/**
Expand All @@ -21,15 +21,15 @@ public class JdbcTypeDescription {
* @param jdbcType type identifier as presented by the JDBC driver of the database
* @param decimalScale number of digits behind the point
* @param precisionOrSize precision for numbers or size for size types (like <code>VARCHAR</code>)
* @param charOctetLength storage size the data type needs in bytes
* @param byteSize storage size the data type needs in bytes
* @param typeName original name the type has in the database
*/
public JdbcTypeDescription(final int jdbcType, final int decimalScale, final int precisionOrSize,
final int charOctetLength, final String typeName) {
final int byteSize, final String typeName) {
this.jdbcType = jdbcType;
this.decimalScale = decimalScale;
this.precisionOrSize = precisionOrSize;
this.charOctetLength = charOctetLength;
this.byteSize = byteSize;
this.typeName = typeName;
}

Expand Down Expand Up @@ -65,8 +65,8 @@ public int getPrecisionOrSize() {
*
* @return size in bytes
*/
public int getCharOctetLength() {
return this.charOctetLength;
public int getByteSize() {
return this.byteSize;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ void testMapJdbcTypeTimestamp() {
equalTo(DataType.createTimestamp(true)));
}

@Test
void testMapJdbcTypeHashtype() {
final JdbcTypeDescription jdbcTypeDescription = new JdbcTypeDescription(
ExasolColumnMetadataReader.EXASOL_HASHTYPE, 0, 0, 16, "HASHTYPE");
assertThat(this.exasolColumnMetadataReader.mapJdbcType(jdbcTypeDescription),
equalTo(DataType.createHashtype(16)));
}

@Test
void testMapJdbcTypeDefault() {
final JdbcTypeDescription jdbcTypeDescription = new JdbcTypeDescription(Types.BOOLEAN, 0, 0, 0, "BOOLEAN");
Expand Down

0 comments on commit 593dcfc

Please sign in to comment.