Skip to content

Commit 97741fa

Browse files
authored
[v1] Rename SPI's type Field to PTypeField (#1730)
1 parent f940a3e commit 97741fa

File tree

19 files changed

+118
-114
lines changed

19 files changed

+118
-114
lines changed

partiql-eval/src/test/kotlin/org/partiql/eval/internal/PartiQLEvaluatorTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.MethodSource
99
import org.partiql.eval.Mode
1010
import org.partiql.eval.compiler.PartiQLCompiler
1111
import org.partiql.spi.types.PType
12+
import org.partiql.spi.types.PTypeField
1213
import org.partiql.spi.value.Datum
1314
import org.partiql.spi.value.Field
1415
import org.partiql.value.PartiQLValue
@@ -1437,7 +1438,7 @@ class PartiQLEvaluatorTest {
14371438
globals = listOf(
14381439
Global(
14391440
name = "t",
1440-
type = PType.row(org.partiql.spi.types.Field.of("a", PType.integer())),
1441+
type = PType.row(PTypeField.of("a", PType.integer())),
14411442
value = Datum.row(Field.of("a", Datum.integer(3)))
14421443
),
14431444
)

partiql-plan/api/partiql-plan.api

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,12 @@ public abstract class org/partiql/plan/rel/RelSort : org/partiql/plan/rel/RelBas
590590
public final class org/partiql/plan/rel/RelType {
591591
public static final field ORDERED I
592592
public fun getDegree ()I
593-
public fun getField (I)Lorg/partiql/spi/types/Field;
594-
public fun getField (Ljava/lang/String;)Lorg/partiql/spi/types/Field;
595-
public fun getFields ()[Lorg/partiql/spi/types/Field;
593+
public fun getField (I)Lorg/partiql/spi/types/PTypeField;
594+
public fun getField (Ljava/lang/String;)Lorg/partiql/spi/types/PTypeField;
595+
public fun getFields ()[Lorg/partiql/spi/types/PTypeField;
596596
public fun isOrdered ()Z
597-
public static fun of ([Lorg/partiql/spi/types/Field;)Lorg/partiql/plan/rel/RelType;
598-
public static fun of ([Lorg/partiql/spi/types/Field;I)Lorg/partiql/plan/rel/RelType;
597+
public static fun of ([Lorg/partiql/spi/types/PTypeField;)Lorg/partiql/plan/rel/RelType;
598+
public static fun of ([Lorg/partiql/spi/types/PTypeField;I)Lorg/partiql/plan/rel/RelType;
599599
}
600600

601601
public abstract class org/partiql/plan/rel/RelUnion : org/partiql/plan/rel/RelBase {

partiql-plan/src/main/java/org/partiql/plan/rel/RelType.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.partiql.plan.rel;
22

33
import org.jetbrains.annotations.NotNull;
4-
import org.partiql.spi.types.Field;
4+
import org.partiql.spi.types.PTypeField;
55

66
/**
77
* Analogous to a ROW type, consider cardinality estimates or other hint mechanisms.
@@ -10,21 +10,21 @@ public final class RelType {
1010

1111
public static final int ORDERED = 0x01;
1212

13-
private final Field[] fields;
13+
private final PTypeField[] fields;
1414
private final boolean ordered;
1515

16-
private RelType(Field[] fields, boolean ordered) {
16+
private RelType(PTypeField[] fields, boolean ordered) {
1717
this.fields = fields;
1818
this.ordered = ordered;
1919
}
2020

2121
@NotNull
22-
public static RelType of(Field... fields) {
22+
public static RelType of(PTypeField... fields) {
2323
return of(fields, 0);
2424
}
2525

2626
@NotNull
27-
public static RelType of(Field[] fields, int properties) {
27+
public static RelType of(PTypeField[] fields, int properties) {
2828
boolean ordered = (properties & ORDERED) != 0;
2929
return new RelType(fields, ordered);
3030
}
@@ -38,21 +38,21 @@ public int getDegree() {
3838
}
3939

4040
@NotNull
41-
public Field[] getFields() {
41+
public PTypeField[] getFields() {
4242
return fields;
4343
}
4444

4545
@NotNull
46-
public Field getField(int index) {
46+
public PTypeField getField(int index) {
4747
if (index < 0 || index >= fields.length) {
4848
throw new IllegalArgumentException("field index out of bounds: " + index);
4949
}
5050
return fields[index]; // bounds check?
5151
}
5252

5353
@NotNull
54-
public Field getField(String name) {
55-
for (Field field : fields) {
54+
public PTypeField getField(String name) {
55+
for (PTypeField field : fields) {
5656
if (field.getName().equals(name)) {
5757
return field;
5858
}

partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import org.partiql.planner.internal.ir.Rel
1818
import org.partiql.planner.internal.ir.SetQuantifier
1919
import org.partiql.planner.internal.ir.visitor.PlanBaseVisitor
2020
import org.partiql.spi.errors.PErrorListener
21-
import org.partiql.spi.types.Field
2221
import org.partiql.spi.types.PType
22+
import org.partiql.spi.types.PTypeField
2323
import org.partiql.planner.internal.ir.PartiQLPlan as IPlan
2424
import org.partiql.planner.internal.ir.PlanNode as INode
2525
import org.partiql.planner.internal.ir.Rel as IRel
@@ -226,7 +226,7 @@ internal class PlanTransform(private val flags: Set<PlannerFlag>) {
226226

227227
override fun visitRel(node: IRel, ctx: PType): org.partiql.plan.rel.Rel {
228228
val o = visitRelOp(node.op, ctx)
229-
val fields = node.type.schema.map { Field.of(it.name, it.type) }.toTypedArray()
229+
val fields = node.type.schema.map { PTypeField.of(it.name, it.type) }.toTypedArray()
230230
val properties = if (node.type.props.contains(Rel.Prop.ORDERED)) RelType.ORDERED else 0
231231
o.type = RelType.of(fields, properties)
232232
return o

partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/CompilerType.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ internal class CompilerType(
1919
internal val isMissingValue: Boolean = false
2020
) : PType(_delegate.code()) {
2121
fun getDelegate(): PType = _delegate
22-
override fun getFields(): MutableCollection<Field> {
22+
override fun getFields(): MutableCollection<PTypeField> {
2323
return _delegate.fields.map { field ->
2424
when (field) {
25-
is Field -> field
26-
else -> Field(field.name, CompilerType(field.type))
25+
is PTypeField -> field
26+
else -> PTypeField(field.name, CompilerType(field.type))
2727
}
2828
}.toMutableList()
2929
}
@@ -53,16 +53,16 @@ internal class CompilerType(
5353
return _delegate.toString()
5454
}
5555

56-
internal class Field(
56+
internal class PTypeField(
5757
private val _name: String,
5858
private val _type: CompilerType
59-
) : org.partiql.spi.types.Field {
59+
) : org.partiql.spi.types.PTypeField {
6060
override fun getName(): String = _name
6161
override fun getType(): CompilerType = _type
6262

6363
override fun equals(other: Any?): Boolean {
6464
if (this === other) return true
65-
if (other !is org.partiql.spi.types.Field) return false
65+
if (other !is org.partiql.spi.types.PTypeField) return false
6666
val nameMatches = _name == other.name
6767
val typeMatches = _type == other.type
6868
return nameMatches && typeMatches

partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ import org.partiql.spi.Context
5757
import org.partiql.spi.catalog.Identifier
5858
import org.partiql.spi.errors.PError
5959
import org.partiql.spi.errors.PErrorListener
60-
import org.partiql.spi.types.Field
6160
import org.partiql.spi.types.PType
61+
import org.partiql.spi.types.PTypeField
6262
import org.partiql.spi.value.Datum
6363
import kotlin.math.max
6464

@@ -149,7 +149,7 @@ internal class PlanTyper(private val env: Env, config: Context) {
149149
}
150150
fields.forEachIndexed { index, field -> fieldTypes[index].add(field.type.toCType()) }
151151
}
152-
val newFields = fieldTypes.mapIndexed { i, types -> Field.of(fieldNames[i], anyOfLiterals(types)!!) }
152+
val newFields = fieldTypes.mapIndexed { i, types -> PTypeField.of(fieldNames[i], anyOfLiterals(types)!!) }
153153
return PType.row(newFields)
154154
}
155155

@@ -986,18 +986,18 @@ internal class PlanTyper(private val env: Env, config: Context) {
986986
rexOpStructField(k, v)
987987
}
988988
var structIsClosed = true
989-
val structTypeFields = mutableListOf<CompilerType.Field>()
989+
val structTypeFields = mutableListOf<CompilerType.PTypeField>()
990990
for (field in fields) {
991991
val keyOp = field.k.op
992992
// TODO: Check key type
993993
if (keyOp !is Rex.Op.Lit || !keyOp.value.isTextValue()) {
994994
structIsClosed = false
995995
continue
996996
}
997-
structTypeFields.add(CompilerType.Field(keyOp.value.string, field.v.type))
997+
structTypeFields.add(CompilerType.PTypeField(keyOp.value.string, field.v.type))
998998
}
999999
val type = when (structIsClosed) {
1000-
true -> CompilerType(PType.row(structTypeFields as Collection<Field>))
1000+
true -> CompilerType(PType.row(structTypeFields as Collection<PTypeField>))
10011001
false -> CompilerType(PType.struct())
10021002
}
10031003
return rex(type, rexOpStruct(fields))
@@ -1185,7 +1185,7 @@ internal class PlanTyper(private val env: Env, config: Context) {
11851185
* unique attributes.
11861186
*/
11871187
private fun calculateTupleUnionOutputType(args: List<CompilerType>): CompilerType? {
1188-
val fields = mutableListOf<CompilerType.Field>()
1188+
val fields = mutableListOf<CompilerType.PTypeField>()
11891189
var structIsOpen = false
11901190
var containsDynamic = false
11911191
var containsNonStruct = false
@@ -1205,7 +1205,7 @@ internal class PlanTyper(private val env: Env, config: Context) {
12051205
containsNonStruct -> null
12061206
containsDynamic -> CompilerType(PType.dynamic())
12071207
structIsOpen -> CompilerType(PType.struct())
1208-
else -> CompilerType(PType.row(fields as Collection<Field>))
1208+
else -> CompilerType(PType.row(fields as Collection<PTypeField>))
12091209
}
12101210
}
12111211

partiql-planner/src/main/kotlin/org/partiql/planner/internal/util/TypeUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ internal object TypeUtils {
4444
val output = fields.mapNotNull { field ->
4545
val newField = if (substeps.isEmpty()) {
4646
if (lastStepOptional) {
47-
CompilerType.Field(field.name, field.type)
47+
CompilerType.PTypeField(field.name, field.type)
4848
} else {
4949
null
5050
}
5151
} else {
5252
val k = field.name
5353
val v = field.type.exclude(substeps, lastStepOptional)
54-
CompilerType.Field(k, v)
54+
CompilerType.PTypeField(k, v)
5555
}
5656
when (type) {
5757
is Rel.Op.Exclude.Type.StructSymbol -> {

partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import org.partiql.spi.Context
1414
import org.partiql.spi.catalog.Catalog
1515
import org.partiql.spi.catalog.Session
1616
import org.partiql.spi.catalog.Table
17-
import org.partiql.spi.types.Field
1817
import org.partiql.spi.types.PType
18+
import org.partiql.spi.types.PTypeField
1919
import org.partiql.types.BagType
2020
import org.partiql.types.StaticType
2121
import org.partiql.types.StructType
@@ -34,8 +34,8 @@ internal class PlannerPErrorReportingTests {
3434
.define(Table.empty("atomic", PType.smallint()))
3535
.define(Table.empty("collection_no_missing_atomic", PType.bag(PType.smallint())))
3636
.define(Table.empty("collection_contain_missing_atomic", PType.bag(PType.smallint())))
37-
.define(Table.empty("struct_no_missing", PType.row(listOf(Field.of("f1", PType.smallint())))))
38-
.define(Table.empty("struct_with_missing", PType.row(listOf(Field.of("f1", PType.smallint())))))
37+
.define(Table.empty("struct_no_missing", PType.row(listOf(PTypeField.of("f1", PType.smallint())))))
38+
.define(Table.empty("struct_with_missing", PType.row(listOf(PTypeField.of("f1", PType.smallint())))))
3939
.build()
4040

4141
private val session = Session.builder()

partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class PlanTyperTest {
6262
)
6363

6464
private val LITERAL_STRUCT_1_FIRST_KEY_TYPE = PType.row(
65-
listOf(CompilerType.Field("sEcoNd_KEY", INT4)),
65+
listOf(CompilerType.PTypeField("sEcoNd_KEY", INT4)),
6666
).toCType()
6767

6868
private val LITERAL_STRUCT_1_TYPED: Rex
6969
get() {
7070
val topLevelStruct = PType.row(
71-
listOf(CompilerType.Field("FiRsT_KeY", LITERAL_STRUCT_1_FIRST_KEY_TYPE)),
71+
listOf(CompilerType.PTypeField("FiRsT_KeY", LITERAL_STRUCT_1_FIRST_KEY_TYPE)),
7272
).toCType()
7373
return rex(
7474
type = topLevelStruct,
@@ -95,17 +95,17 @@ class PlanTyperTest {
9595

9696
private val ORDERED_DUPLICATES_STRUCT = PType.row(
9797
listOf(
98-
CompilerType.Field("definition", STRING),
99-
CompilerType.Field("definition", DOUBLE_PRECISION),
100-
CompilerType.Field("DEFINITION", DECIMAL),
98+
CompilerType.PTypeField("definition", STRING),
99+
CompilerType.PTypeField("definition", DOUBLE_PRECISION),
100+
CompilerType.PTypeField("DEFINITION", DECIMAL),
101101
),
102102
).toCType()
103103

104104
private val DUPLICATES_STRUCT = PType.row(
105105
listOf(
106-
CompilerType.Field("definition", STRING),
107-
CompilerType.Field("definition", DOUBLE_PRECISION),
108-
CompilerType.Field("DEFINITION", DECIMAL),
106+
CompilerType.PTypeField("definition", STRING),
107+
CompilerType.PTypeField("definition", DOUBLE_PRECISION),
108+
CompilerType.PTypeField("DEFINITION", DECIMAL),
109109
),
110110
).toCType()
111111

0 commit comments

Comments
 (0)