You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/16 00:00:21 UTC

[GitHub] [spark] rdblue commented on a change in pull request #23848: [SPARK-26946][SQL] Identifiers for multi-catalog

rdblue commented on a change in pull request #23848: [SPARK-26946][SQL] Identifiers for multi-catalog
URL: https://github.com/apache/spark/pull/23848#discussion_r266178103
 
 

 ##########
 File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/v2/ResolveMultipartRelationSuite.scala
 ##########
 @@ -0,0 +1,98 @@
+/*
+ * 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.catalyst.catalog.v2
+
+import org.apache.spark.sql.catalog.v2.{CatalogNotFoundException, CatalogPlugin}
+import org.apache.spark.sql.catalyst.CatalogIdentifier
+import org.apache.spark.sql.catalyst.analysis.{AnalysisTest, Analyzer, EliminateSubqueryAliases, NamedRelation}
+import org.apache.spark.sql.catalyst.expressions.Attribute
+import org.apache.spark.sql.catalyst.parser.CatalystSqlParser
+import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan}
+import org.apache.spark.sql.catalyst.rules.Rule
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+private case class TestUnresolvedMultipartRelation(parts: Seq[String])
+    extends LeafNode with NamedRelation {
+
+  override def name: String = "TestUnresolvedMultipartRelation"
+
+  override def output: Seq[Attribute] = Nil
+
+  override lazy val resolved = false
+}
+
+private case class TestMultipartRelation(catalog: Option[CatalogPlugin], ident: CatalogIdentifier)
+    extends LeafNode with NamedRelation {
+
+  override def name: String = "TestMultipartRelation"
+
+  override def output: Seq[Attribute] = Nil
+
+  override lazy val resolved = true
+}
+
+private case class TestMultipartAnalysis(analyzer: Analyzer) extends Rule[LogicalPlan] {
+
+  override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators  {
+
+    case TestUnresolvedMultipartRelation(analyzer.CatalogRef(catalog, ident)) =>
+      TestMultipartRelation(catalog, ident)
+  }
+}
+
+private class TestCatalogPlugin(override val name: String) extends CatalogPlugin {
+
+  override def initialize(name: String, options: CaseInsensitiveStringMap): Unit = Unit
+}
+
+class ResolveMultipartRelationSuite extends AnalysisTest {
+  import CatalystSqlParser._
+
+  private val analyzer = makeAnalyzer(caseSensitive = false)
+
+  private val catalogs = Seq("prod", "test").map(name => name -> new TestCatalogPlugin(name)).toMap
 
 Review comment:
   Why not use the plugin system to instantiate these catalogs?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org