ImpalaDatabaseDialect extends Hive2DatabaseDialect { @Override public String getURL( IDatabaseConnection connection ) throws DatabaseDialectException { StringBuffer urlBuffer = new StringBuffer( getNativeJdbcPre() ); urlBuffer.append( connection.getHostname() ); urlBuffer.append( ":" ); urlBuffer.append( connection.getDatabasePort() ); urlBuffer.append( "/" ); urlBuffer.append( connection.getDatabaseName() ); String principalPropertyName = getDatabaseType().getShortName() + ".principal"; String principal = connection.getExtraOptions().get( principalPropertyName ); String extraPrincipal = connection.getAttributes().get( DatabaseConnection.ATTRIBUTE_PREFIX_EXTRA_OPTION + principalPropertyName ); urlBuffer.append( ";impala_db=true" ); if ( principal != null || extraPrincipal != null ) { return urlBuffer.toString(); } urlBuffer.append( ";auth=noSasl" ); return urlBuffer.toString(); } ImpalaDatabaseDialect(); IDatabaseType getDatabaseType(); @Override String getNativeDriver(); @Override String getURL( IDatabaseConnection connection ); @Override String getNativeJdbcPre(); @Override String[] getUsedLibraries(); @Override int getDefaultDatabasePort(); @Override boolean initialize( String classname );  }
@Test public void testGetURL() throws Exception { ImpalaDatabaseDialect impala = new ImpalaDatabaseDialect(); DatabaseConnection dbconn = new DatabaseConnection(); String url = impala.getURL( dbconn ); assertEquals( "noauth url", "jdbc:hive2: dbconn.addExtraOption( impala.getDatabaseType().getShortName(), "principal", "someValue" ); url = impala.getURL( dbconn ); assertEquals( "principal url", "jdbc:hive2: }