From 8d9ded8b1e15b691bf182f138cf6f12cc87a55d5 Mon Sep 17 00:00:00 2001 From: John Ed Quinn Date: Mon, 9 Dec 2024 12:14:40 -0800 Subject: [PATCH] Updates usages of Collection to List in partiql-spi --- .../partiql/planner/internal/TestCatalog.kt | 2 +- partiql-spi/api/partiql-spi.api | 22 +++++++++---------- .../org/partiql/spi/catalog/Identifier.kt | 8 +++---- .../kotlin/org/partiql/spi/catalog/Name.kt | 4 ++-- .../org/partiql/spi/catalog/Namespace.kt | 2 +- .../kotlin/org/partiql/spi/catalog/Session.kt | 2 +- .../spi/catalog/impl/StandardCatalog.kt | 3 --- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/TestCatalog.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/TestCatalog.kt index 4d91c53f7..960c14a66 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/TestCatalog.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/TestCatalog.kt @@ -24,7 +24,7 @@ public class TestCatalog private constructor( for (part in name) { curr = curr.get(Identifier.delimited(part).first()) ?: break } - return null + return curr.table } override fun resolveTable(session: Session, identifier: Identifier): Name? { diff --git a/partiql-spi/api/partiql-spi.api b/partiql-spi/api/partiql-spi.api index e1d037011..4d308d4b5 100644 --- a/partiql-spi/api/partiql-spi.api +++ b/partiql-spi/api/partiql-spi.api @@ -124,7 +124,7 @@ public final class org/partiql/spi/catalog/Identifier : java/lang/Iterable, kotl public final fun append (Lorg/partiql/spi/catalog/Identifier;)Lorg/partiql/spi/catalog/Identifier; public final fun append ([Lorg/partiql/spi/catalog/Identifier$Part;)Lorg/partiql/spi/catalog/Identifier; public static final fun delimited (Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; - public static final fun delimited (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Identifier; + public static final fun delimited (Ljava/util/List;)Lorg/partiql/spi/catalog/Identifier; public static final fun delimited ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; public fun equals (Ljava/lang/Object;)Z public fun forEach (Ljava/util/function/Consumer;)V @@ -136,10 +136,10 @@ public final class org/partiql/spi/catalog/Identifier : java/lang/Iterable, kotl public fun iterator ()Ljava/util/Iterator; public final fun matches (Ljava/lang/String;Z)Z public static synthetic fun matches$default (Lorg/partiql/spi/catalog/Identifier;Ljava/lang/String;ZILjava/lang/Object;)Z - public static final fun of (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Identifier; + public static final fun of (Ljava/util/List;)Lorg/partiql/spi/catalog/Identifier; public static final fun of ([Lorg/partiql/spi/catalog/Identifier$Part;)Lorg/partiql/spi/catalog/Identifier; public static final fun regular (Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; - public static final fun regular (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Identifier; + public static final fun regular (Ljava/util/List;)Lorg/partiql/spi/catalog/Identifier; public static final fun regular ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; public fun spliterator ()Ljava/util/Spliterator; public fun toString ()Ljava/lang/String; @@ -147,12 +147,12 @@ public final class org/partiql/spi/catalog/Identifier : java/lang/Iterable, kotl public final class org/partiql/spi/catalog/Identifier$Companion { public final fun delimited (Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; - public final fun delimited (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Identifier; + public final fun delimited (Ljava/util/List;)Lorg/partiql/spi/catalog/Identifier; public final fun delimited ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; - public final fun of (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Identifier; + public final fun of (Ljava/util/List;)Lorg/partiql/spi/catalog/Identifier; public final fun of ([Lorg/partiql/spi/catalog/Identifier$Part;)Lorg/partiql/spi/catalog/Identifier; public final fun regular (Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; - public final fun regular (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Identifier; + public final fun regular (Ljava/util/List;)Lorg/partiql/spi/catalog/Identifier; public final fun regular ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Identifier; } @@ -184,14 +184,14 @@ public final class org/partiql/spi/catalog/Name : java/lang/Iterable, kotlin/jvm public final fun hasNamespace ()Z public fun hashCode ()I public fun iterator ()Ljava/util/Iterator; - public static final fun of (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Name; + public static final fun of (Ljava/util/List;)Lorg/partiql/spi/catalog/Name; public static final fun of ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Name; public fun spliterator ()Ljava/util/Spliterator; public fun toString ()Ljava/lang/String; } public final class org/partiql/spi/catalog/Name$Companion { - public final fun of (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Name; + public final fun of (Ljava/util/List;)Lorg/partiql/spi/catalog/Name; public final fun of ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Name; } @@ -208,7 +208,7 @@ public final class org/partiql/spi/catalog/Namespace : java/lang/Iterable, kotli public fun hashCode ()I public final fun isEmpty ()Z public fun iterator ()Ljava/util/Iterator; - public static final fun of (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Namespace; + public static final fun of (Ljava/util/List;)Lorg/partiql/spi/catalog/Namespace; public static final fun of ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Namespace; public fun spliterator ()Ljava/util/Spliterator; public fun toString ()Ljava/lang/String; @@ -216,7 +216,7 @@ public final class org/partiql/spi/catalog/Namespace : java/lang/Iterable, kotli public final class org/partiql/spi/catalog/Namespace$Companion { public final fun empty ()Lorg/partiql/spi/catalog/Namespace; - public final fun of (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Namespace; + public final fun of (Ljava/util/List;)Lorg/partiql/spi/catalog/Namespace; public final fun of ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Namespace; } @@ -255,7 +255,7 @@ public final class org/partiql/spi/catalog/Session$Builder { public final fun catalog (Ljava/lang/String;)Lorg/partiql/spi/catalog/Session$Builder; public final fun catalogs ([Lorg/partiql/spi/catalog/Catalog;)Lorg/partiql/spi/catalog/Session$Builder; public final fun identity (Ljava/lang/String;)Lorg/partiql/spi/catalog/Session$Builder; - public final fun namespace (Ljava/util/Collection;)Lorg/partiql/spi/catalog/Session$Builder; + public final fun namespace (Ljava/util/List;)Lorg/partiql/spi/catalog/Session$Builder; public final fun namespace (Lorg/partiql/spi/catalog/Namespace;)Lorg/partiql/spi/catalog/Session$Builder; public final fun namespace ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Session$Builder; public final fun property (Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/spi/catalog/Session$Builder; diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Identifier.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Identifier.kt index fd9c7a93d..bacba281e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Identifier.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Identifier.kt @@ -30,7 +30,7 @@ public class Identifier private constructor( public fun hasQualifier(): Boolean = qualifier.isNotEmpty() /** - * Returns a collection of the identifier parts. + * Returns an ordered collection of the identifier parts. */ public fun getParts(): List { return listOf(*qualifier) + identifier @@ -195,7 +195,7 @@ public class Identifier private constructor( public fun regular(vararg parts: String): Identifier = regular(parts.toList()) @JvmStatic - public fun regular(parts: Collection): Identifier { + public fun regular(parts: List): Identifier { if (parts.isEmpty()) { error("Cannot create an identifier with no parts") } @@ -211,7 +211,7 @@ public class Identifier private constructor( public fun delimited(vararg parts: String): Identifier = delimited(parts.toList()) @JvmStatic - public fun delimited(parts: Collection): Identifier { + public fun delimited(parts: List): Identifier { if (parts.isEmpty()) { error("Cannot create an identifier with no parts") } @@ -224,7 +224,7 @@ public class Identifier private constructor( public fun of(vararg parts: Part): Identifier = of(parts.toList()) @JvmStatic - public fun of(parts: Collection): Identifier { + public fun of(parts: List): Identifier { if (parts.isEmpty()) { error("Cannot create an identifier with no parts") } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Name.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Name.kt index a089be9f1..5611efd44 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Name.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Name.kt @@ -88,10 +88,10 @@ public class Name( public fun of(vararg names: String): Name = of(names.toList()) /** - * Construct a name from a collection of strings. + * Construct a name from an ordered collection of strings. */ @JvmStatic - public fun of(names: Collection): Name { + public fun of(names: List): Name { assert(names.size > 0) { "Cannot create an empty name" } val namespace = Namespace.of(names.take(names.size - 1)) val name = names.last() diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt index 170bf5b98..ee09c0675 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt @@ -92,7 +92,7 @@ public class Namespace private constructor( } @JvmStatic - public fun of(levels: Collection): Namespace { + public fun of(levels: List): Namespace { if (levels.isEmpty()) { return empty() } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Session.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Session.kt index 4ce68c0dc..42c633bdc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Session.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Session.kt @@ -86,7 +86,7 @@ public interface Session { return this } - public fun namespace(levels: Collection): Builder { + public fun namespace(levels: List): Builder { this.namespace = Namespace.of(levels) return this } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/impl/StandardCatalog.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/impl/StandardCatalog.kt index 76ae1547c..83a43763c 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/impl/StandardCatalog.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/impl/StandardCatalog.kt @@ -28,9 +28,6 @@ internal class StandardCatalog( */ override fun resolveTable(session: Session, identifier: Identifier): Name? { // TODO memory connector does not handle qualified identifiers and longest match - if (identifier.hasQualifier()) { - return null - } val first = identifier.first() for ((name, _) in tables) { val str = name.getName() // only use single identifiers for now