ImpalaDatabaseMeta extends Hive2DatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean useAutoinc, boolean addFieldname, boolean addCr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( addFieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_BOOLEAN: retval += "BOOLEAN"; break; case ValueMetaInterface.TYPE_DATE: case ValueMetaInterface.TYPE_TIMESTAMP: if ( isDriverVersion( 0, 8 ) ) { retval += "TIMESTAMP"; } else { throw new IllegalArgumentException( "Timestamp types not supported in this version of Impala" ); } break; case ValueMetaInterface.TYPE_STRING: retval += "STRING"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( precision == 0 ) { if ( length > 9 ) { if ( length < 19 ) { retval += "BIGINT"; } else { retval += "FLOAT"; } } else { retval += "INT"; } } else { if ( length > 15 ) { retval += "FLOAT"; } else { retval += "DOUBLE"; } } break; } return retval; } ImpalaDatabaseMeta( DriverLocator driverLocator, NamedClusterService namedClusterService,
                             MetastoreLocator metastoreLocator ); @Override int[] getAccessTypeList(); @Override String getDriverClass(); @Override String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean useAutoinc,
                                    boolean addFieldname, boolean addCr ); @Override String getURL( String hostname, String port, String databaseName ); @Override String[] getUsedLibraries(); @Override int getDefaultDatabasePort(); @Override List<String> getNamedClusterList(); @Override void putOptionalOptions( Map<String, String> extraOptions ); static final String AUTH_NO_SASL; }
@Test public void testGetFieldDefinition() { assertGetFieldDefinition( new ValueMetaInternetAddress(), "internetAddressName", "" ); }