-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-45880][SQL] Make the like pattern semantics used in all commands consistent
#43751
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 2 commits
e418b3d
43bfe0f
bf18462
c51043f
55fa734
3fa8e9a
315c8b7
48acc95
c414e8e
596de52
6181d3c
4d382ef
677f2c9
3992a7d
4b096f2
3a43818
2aeb620
7abf241
b276a3d
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 |
|---|---|---|
|
|
@@ -17,7 +17,16 @@ | |
|
|
||
| package org.apache.spark.sql.connector.catalog; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import scala.jdk.javaapi.CollectionConverters; | ||
|
|
||
| import org.apache.spark.annotation.Evolving; | ||
| import org.apache.spark.sql.catalyst.util.StringUtils; | ||
| import org.apache.spark.sql.connector.expressions.Transform; | ||
| import org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException; | ||
| import org.apache.spark.sql.catalyst.analysis.NoSuchTableException; | ||
|
|
@@ -26,10 +35,6 @@ | |
| import org.apache.spark.sql.errors.QueryExecutionErrors; | ||
| import org.apache.spark.sql.types.StructType; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Catalog methods for working with Tables. | ||
| * <p> | ||
|
|
@@ -97,6 +102,26 @@ public interface TableCatalog extends CatalogPlugin { | |
| */ | ||
| Identifier[] listTables(String[] namespace) throws NoSuchNamespaceException; | ||
|
|
||
| /** | ||
| * List the tables in a namespace from the catalog by pattern string. | ||
| * <p> | ||
| * If the catalog supports views, this must return identifiers for only tables and not views. | ||
| * | ||
| * @param namespace a multi-part namespace | ||
| * @param pattern the filter pattern, only '*' and '|' are allowed as wildcards, others will | ||
| * follow regular expression convention, case-insensitive match and white spaces | ||
| * on both ends will be ignored | ||
|
||
| * @return an array of Identifiers for tables | ||
| * @throws NoSuchNamespaceException If the namespace does not exist (optional). | ||
| */ | ||
| default Identifier[] listTables(String[] namespace, String pattern) | ||
| throws NoSuchNamespaceException { | ||
| List<String> tableNames = Arrays.stream(listTables(namespace)).map(Identifier::name).toList(); | ||
| return CollectionConverters.asJava(StringUtils.filterPattern( | ||
| CollectionConverters.asScala(tableNames).toSeq(), pattern)).stream().map( | ||
| name -> Identifier.of(namespace, name)).toArray(Identifier[]::new); | ||
| } | ||
|
|
||
| /** | ||
| * Load table metadata by {@link Identifier identifier} from the catalog. | ||
| * <p> | ||
|
|
||


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 the existing doc is a bit vague.
|is not a wildcard, right? And|is also a valid syntax in regex. Can we take a look at other databases and see how they document it?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.
Okay, let me investigate it.