yiheng commented on a change in pull request #194: [LIVY-622][LIVY-623][LIVY-624][LIVY-625][Thrift]Support GetFunctions, GetSchemas, GetTables, GetColumns in Livy thrift server URL: https://github.com/apache/incubator-livy/pull/194#discussion_r313313340
########## File path: thriftserver/session/src/main/java/org/apache/livy/thriftserver/session/GetSchemasJob.java ########## @@ -0,0 +1,52 @@ +/* + * 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.livy.thriftserver.session; + +import java.util.ArrayList; +import java.util.List; + +import scala.Option; +import static scala.collection.JavaConversions.seqAsJavaList; + +import org.apache.spark.sql.Row; +import org.apache.spark.sql.execution.command.ShowDatabasesCommand; + +import org.apache.livy.Job; +import org.apache.livy.JobContext; + +public class GetSchemasJob implements Job<List<Object[]>> { + private final String schemaName; + + public GetSchemasJob(String schemaName) { + this.schemaName = schemaName; + } + + @Override + public List<Object[]> call(JobContext jc) throws Exception { + ShowDatabasesCommand cmd = new ShowDatabasesCommand(Option.apply(schemaName)); + List<Row> rows = seqAsJavaList(cmd.run(jc.sparkSession())); + List<Object[]> schemas = new ArrayList<>(); + for(Row r : rows) { + schemas.add(new Object[]{ + r.getString(0), + "" Review comment: Refer to Spark thrift server. The schema catalog field is not supported in spark, so here return an empty string. This is related spark code [code1](https://github.com/apache/spark/blob/master/sql/hive-thriftserver/v2.3.5/src/main/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java#L65) [code2](https://github.com/apache/spark/blob/master/sql/hive-thriftserver/v2.3.5/src/main/java/org/apache/hive/service/cli/operation/MetadataOperation.java#L42) Use a meaningful variable to hold the value [code](https://github.com/apache/incubator-livy/pull/194/files#diff-7305b5c4ce94be1ec420c37d16dc202dR30) ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services