-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KYUUBI-156][KYUUBI-185] Implementing all meta operations support by …
…spark (#191) * [KYUUBI-156][KYUUBI-185] Implementing all meta operations support by spark * rm used metastore client fix #156 fix #185 * add more uts * add more uts * fix bugs and add show functions * meta operation method abstraction * readme
- Loading branch information
Showing
36 changed files
with
1,939 additions
and
747 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...rver/src/main/scala/org/apache/spark/sql/execution/command/KyuubiShowColumnsCommand.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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.spark.sql.execution.command | ||
|
||
import org.apache.spark.sql.{Row, SparkSession} | ||
|
||
import yaooqinn.kyuubi.schema.SchemaMapper | ||
|
||
case class KyuubiShowColumnsCommand( | ||
databasePattern: String, | ||
tableIdentifierPattern: String, | ||
columnPattern: String) extends RunnableCommand { | ||
|
||
override def run(sparkSession: SparkSession): Seq[Row] = { | ||
val catalog = sparkSession.sessionState.catalog | ||
val pattern = columnPattern.r.pattern | ||
val databases = catalog.listDatabases(databasePattern) | ||
val tableIdentifiers = databases.flatMap { db => | ||
catalog.listTables(db, tableIdentifierPattern) | ||
} | ||
val tables = tableIdentifiers.map(catalog.getTempViewOrPermanentTableMetadata) | ||
val result = tables.flatMap { table => | ||
table.schema | ||
.filter(f => pattern.matcher(f.name).matches()) | ||
.zipWithIndex.map { case (f, i) => | ||
Row( | ||
"", // TABLE_CAT | ||
table.database, // TABLE_SCHEM | ||
table.identifier.table, // TABLE_NAME | ||
f.name, // COLUMN_NAME | ||
SchemaMapper.toJavaSQLType(f.dataType), // DATA_TYPE | ||
f.dataType.typeName, // TYPE_NAME | ||
SchemaMapper.getColumnSize(f.dataType).orNull, // COLUMN_SIZE | ||
null, // BUFFER_LENGTH, unused | ||
SchemaMapper.getDecimalDigits(f.dataType).orNull, // DECIMAL_DIGITS | ||
SchemaMapper.getNumPrecRadix(f.dataType).orNull, // NUM_PREC_RADIX | ||
if (f.nullable) 1 else 0, // NULLABLE | ||
f.getComment().getOrElse(""), // | ||
null, // COLUMN_DEF | ||
null, // SQL_DATA_TYPE | ||
null, // SQL_DATETIME_SUB | ||
null, // CHAR_OCTET_LENGTH | ||
i, // ORDINAL_POSITION | ||
if (f.nullable) "YES" else "NO", // IS_NULLABLE | ||
null, // SCOPE_CATALOG | ||
null, // SCOPE_SCHEMA | ||
null, // SCOPE_TABLE | ||
null, // SOURCE_DATA_TYPE | ||
"NO" // IS_AUTO_INCREMENT | ||
) | ||
} | ||
} | ||
result | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...er/src/main/scala/org/apache/spark/sql/execution/command/KyuubiShowFunctionsCommand.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.spark.sql.execution.command | ||
|
||
import org.apache.spark.sql.{Row, SparkSession} | ||
|
||
case class KyuubiShowFunctionsCommand( | ||
databasePattern: String, | ||
functionName: String) extends RunnableCommand { | ||
override def run(sparkSession: SparkSession): Seq[Row] = { | ||
val catalog = sparkSession.sessionState.catalog | ||
val databases = catalog.listDatabases(databasePattern) | ||
databases.flatMap { db => | ||
catalog.listFunctions(db, functionName).map { case (f, typ) => | ||
val info = catalog.lookupFunctionInfo(f) | ||
Row( | ||
typ, | ||
f.database.orNull, | ||
f.funcName, | ||
info.getUsage + info.getExtended, | ||
null, | ||
info.getClassName | ||
) | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...erver/src/main/scala/org/apache/spark/sql/execution/command/KyuubiShowTablesCommand.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.spark.sql.execution.command | ||
|
||
import org.apache.spark.sql.{Row, SparkSession} | ||
|
||
case class KyuubiShowTablesCommand( | ||
databaseName: String, | ||
tableIdentifierPattern: String, | ||
tableTypes: Seq[String]) extends RunnableCommand { | ||
|
||
override def run(sparkSession: SparkSession): Seq[Row] = { | ||
val catalog = sparkSession.sessionState.catalog | ||
val databases = catalog.listDatabases(databaseName) | ||
val tableIdentifiers = databases.flatMap { db => catalog.listTables(db, tableIdentifierPattern)} | ||
val types = tableTypes.map(_.toUpperCase) | ||
|
||
val tables = tableIdentifiers.map(catalog.getTempViewOrPermanentTableMetadata) | ||
tables.flatMap { table => | ||
val tableType = table.tableType.name | ||
if (types.contains(tableType)) { | ||
Some( | ||
Row("", table.database, table.identifier.table, tableType, table.comment.getOrElse("")) | ||
) | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 0 additions & 195 deletions
195
kyuubi-server/src/main/scala/yaooqinn/kyuubi/operation/AbstractKyuubiOperation.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.