hit-lacus commented on a change in pull request #747: KYLIN-3832 Query pushdown support postgresql URL: https://github.com/apache/kylin/pull/747#discussion_r339345790
########## File path: datasource-sdk/src/main/java/org/apache/kylin/sdk/datasource/adaptor/PostgresqlAdaptor.java ########## @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kylin.sdk.datasource.adaptor; + +import javax.sql.rowset.CachedRowSet; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.ArrayList; + + +public class PostgresqlAdaptor extends DefaultAdaptor { + public PostgresqlAdaptor(AdaptorConfig config) throws Exception { + super(config); + } + + @Override + public List<String> listDatabases() throws SQLException { + List<String> ret = new ArrayList<>(); + try (Connection con = getConnection()) { + ret.add(con.getCatalog()); + } + return ret; + } + + @Override + public List<String> listTables(String catalog) throws SQLException { + List<String> ret = new ArrayList<>(); + String[] tableTypes = {"TABLE"}; + try (Connection con = getConnection(); ResultSet res = con.getMetaData().getTables(catalog, null, null, tableTypes)) { + String table; + while (res.next()) { + String schem = res.getString("TABLE_SCHEM"); + if (schem.equals(catalog)) { Review comment: Should we compare the name of schema with the name of database? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
