-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-30214][SQL] A new framework to resolve v2 commands #26847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
a005713
7c45c9b
024ab39
e489e62
9b272b6
85617cd
e33a200
3e37941
7df9407
57c83fc
ccc4702
72c01a9
1a7c800
415de11
6ab2228
56037ff
6675e7f
a42e12e
2c458f0
573a66e
f6e742b
0754656
a868420
5a6aa2a
0b89d3a
a41acc5
de054c7
e0836f6
fc555be
7b4f3e3
9f2159f
70028dd
9d10239
c391212
d20b1b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * 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.analysis | ||
|
|
||
| import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
| import org.apache.spark.sql.catalyst.rules.Rule | ||
| import org.apache.spark.sql.connector.catalog.{CatalogManager, CatalogV2Util, LookupCatalog} | ||
| import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._ | ||
|
|
||
| case class ResolveNamespaceAndTable(catalogManager: CatalogManager) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this add an analyzer rule? There is already a pattern used to alter tables and namespaces that should be used instead. |
||
| extends Rule[LogicalPlan] with LookupCatalog { | ||
| override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators { | ||
| case UnresolvedNamespace(CatalogAndNamespace(catalog, ns)) => | ||
| ResolvedNamespace(catalog.asNamespaceCatalog, ns) | ||
|
|
||
| case u @ UnresolvedV2Table(CatalogAndIdentifier(catalog, ident)) => | ||
|
yaooqinn marked this conversation as resolved.
Outdated
|
||
| CatalogV2Util.loadTable(catalog, ident).map { _ => | ||
| ResolvedV2Table(catalog.asTableCatalog, ident) | ||
| }.getOrElse(u) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * 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.analysis | ||
|
|
||
| import org.apache.spark.sql.catalyst.expressions.Attribute | ||
| import org.apache.spark.sql.catalyst.plans.logical.LeafNode | ||
| import org.apache.spark.sql.connector.catalog.SupportsNamespaces | ||
|
|
||
| case class ResolvedNamespace(catalog: SupportsNamespaces, namespace: Seq[String]) | ||
| extends LeafNode { | ||
| override def output: Seq[Attribute] = Nil | ||
| } | ||
|
|
||
| case class UnresolvedNamespace(multipartIdentifier: Seq[String]) extends LeafNode { | ||
| override lazy val resolved: Boolean = false | ||
|
|
||
| override def output: Seq[Attribute] = Nil | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * 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.analysis | ||
|
|
||
| import org.apache.spark.sql.catalyst.expressions.Attribute | ||
| import org.apache.spark.sql.catalyst.plans.logical.LeafNode | ||
| import org.apache.spark.sql.connector.catalog.{Identifier, TableCatalog} | ||
|
|
||
| case class ResolvedV2Table(catalog: TableCatalog, identifier: Identifier) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should work like existing alter table plans and does not need to introduce new nodes.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's define it as |
||
| extends LeafNode { | ||
| override def output: Seq[Attribute] = Nil | ||
| } | ||
|
|
||
| case class UnresolvedV2Table(multipartIdentifier: Seq[String]) extends LeafNode { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to remove
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you miss this one? |
||
| override lazy val resolved: Boolean = false | ||
|
|
||
| override def output: Seq[Attribute] = Nil | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to this PR, but I have seen (database | NAMESPACE) too many times.
Maybe we should have a
and use
namespacedirectly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #27027 for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! merged