Skip to content

Commit

Permalink
added support for querying views in PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
albertocsm committed Dec 14, 2015
1 parent df2e649 commit 0a75bb2
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.google.common.base.Throwables;
import io.airlift.slice.Slice;

import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Types;

import org.postgresql.Driver;
Expand Down Expand Up @@ -117,4 +119,17 @@ protected Type toPrestoType(int jdbcType)
return VARBINARY;
}
}

@Override
protected ResultSet getTables(Connection connection, String schemaName, String tableName)
throws SQLException
{
DatabaseMetaData metadata = connection.getMetaData();
String escape = metadata.getSearchStringEscape();
return metadata.getTables(
connection.getCatalog(),
escapeNamePattern(schemaName, escape),
escapeNamePattern(tableName, escape),
new String[] {"TABLE", "VIEW"});
}
}

0 comments on commit 0a75bb2

Please sign in to comment.