Skip to content

Commit bced255

Browse files
committed
Align Java integration fixtures with VGI conformance
1 parent 8d93038 commit bced255

3 files changed

Lines changed: 124 additions & 1 deletion

File tree

ci/run-integration.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ mkdir -p "$STAGE/test/sql/integration"
6767
awk -v http="$AWK_HTTP" -f "$HERE/preprocess-require.awk" "$f" > "$STAGE/test/sql/integration/$f"
6868
done )
6969

70+
# The database-worker tests package this executable through a path relative to
71+
# the staged unittest working directory. Staging only .test files leaves that
72+
# path unmatched, so preserve the fixture and its executable bit explicitly.
73+
DATABASE_WORKER_FIXTURE="$VGI_SRC/test/support/database_worker_fixture.sh"
74+
if [ ! -f "$DATABASE_WORKER_FIXTURE" ]; then
75+
echo "::error::pinned VGI suite is missing $DATABASE_WORKER_FIXTURE" >&2
76+
exit 1
77+
fi
78+
mkdir -p "$STAGE/test/support"
79+
install -m 0755 "$DATABASE_WORKER_FIXTURE" \
80+
"$STAGE/test/support/database_worker_fixture.sh"
81+
7082
# Transport recap (resolved above, before staging):
7183
# launch — flock-coordinated AF_UNIX worker pool, amortising JVM cold-start
7284
# across the run. Set VGI_RPC_SHM_SIZE_BYTES to also exercise the
@@ -225,6 +237,9 @@ EXPECTED_SKIP_REASONS=(
225237
'require-env VGI_DOCKER_IMAGE' # containerised worker lane
226238
'require-env VGI_DOCKER_TCP_IMAGE' # containerised worker over TCP
227239
'require-env VGI_GITHUB_NETWORK_TESTS' # hits github.com; opt-in only
240+
'require-env VGI_DATABASE_BUN_WORKER' # Bun package fixture belongs to its SDK lane
241+
'require-env VGI_DATABASE_PYTHON_WORKER' # Python package fixture belongs to its SDK lane
242+
'require-env VGI_DATABASE_RUST_WORKER' # Rust package fixture belongs to its SDK lane
228243
# table_buffering_{worker_crash,pool_recovery}: their crash_on_process fixture
229244
# SIGKILLs the worker serving it, and both files ATTACH ${VGI_TEST_WORKER} —
230245
# a SHARED worker on every lane here (launch/shm share one launcher JVM, http

vgi-example-worker/src/main/java/farm/query/vgi/example/Main.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,11 @@ private static void registerScalars(Worker w) {
506506
.registerTable("main",
507507
new farm.query.vgi.example.table.SameNameCachedFunctions.MainSchema())
508508
.registerTable("data",
509-
new farm.query.vgi.example.table.SameNameCachedFunctions.DataSchema());
509+
new farm.query.vgi.example.table.SameNameCachedFunctions.DataSchema())
510+
.registerTable("main",
511+
new farm.query.vgi.example.table.SameNameTableFunctions.MainSchema())
512+
.registerTable("data",
513+
new farm.query.vgi.example.table.SameNameTableFunctions.DataSchema());
510514
}
511515

512516
private static void registerTables(Worker w) {
@@ -734,6 +738,18 @@ private static CatalogTable lateMatTable(String name, String comment,
734738

735739
private static void registerCatalogTables(Worker w) {
736740
w.registerCatalogTable(CatalogTable.functionBacked(
741+
"main", farm.query.vgi.example.table.SameNameTableFunctions.TABLE_NAME,
742+
SchemaUtil.serializeSchema(
743+
farm.query.vgi.example.table.SameNameTableFunctions.OUTPUT),
744+
"Schema-disambiguation probe; the main-schema table",
745+
farm.query.vgi.example.table.SameNameTableFunctions.FUNCTION_NAME))
746+
.registerCatalogTable(CatalogTable.functionBacked(
747+
"data", farm.query.vgi.example.table.SameNameTableFunctions.TABLE_NAME,
748+
SchemaUtil.serializeSchema(
749+
farm.query.vgi.example.table.SameNameTableFunctions.OUTPUT),
750+
"Schema-disambiguation probe; the data-schema table",
751+
farm.query.vgi.example.table.SameNameTableFunctions.FUNCTION_NAME))
752+
.registerCatalogTable(CatalogTable.functionBacked(
737753
"data", "ten_thousand_table",
738754
SchemaUtil.serializeSchema(
739755
new Schema(List.of(
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright 2026 Query Farm LLC - https://query.farm
2+
3+
package farm.query.vgi.example.table;
4+
5+
import farm.query.vgi.function.FunctionMetadata;
6+
import farm.query.vgi.function.FunctionSpec;
7+
import farm.query.vgi.internal.BatchUtil;
8+
import farm.query.vgi.protocol.FunctionExample;
9+
import farm.query.vgi.table.SimpleTableFunction;
10+
import farm.query.vgi.table.TableInitParams;
11+
import farm.query.vgi.table.TableProducerState;
12+
import farm.query.vgi.types.Schemas;
13+
import farm.query.vgirpc.CallContext;
14+
import farm.query.vgirpc.OutputCollector;
15+
import org.apache.arrow.vector.VarCharVector;
16+
import org.apache.arrow.vector.types.pojo.Schema;
17+
import org.apache.arrow.vector.util.Text;
18+
19+
import java.util.List;
20+
21+
/** Same-named scan functions backing same-named declarative tables in two schemas. */
22+
public final class SameNameTableFunctions {
23+
24+
private SameNameTableFunctions() {}
25+
26+
/** Deliberately colliding scan-function name. */
27+
public static final String FUNCTION_NAME = "test_same_name_table_scan";
28+
/** Deliberately colliding declarative table name. */
29+
public static final String TABLE_NAME = "test_same_name_table";
30+
/** Shared one-column output schema. */
31+
public static final Schema OUTPUT = Schemas.of(Schemas.nullable("tag", Schemas.UTF8));
32+
33+
abstract static class Tagging extends SimpleTableFunction {
34+
abstract String owningSchema();
35+
36+
@Override protected Schema outputSchema() { return OUTPUT; }
37+
38+
@Override public TableProducerState createProducer(TableInitParams params) {
39+
return new State(owningSchema());
40+
}
41+
}
42+
43+
/** One-shot schema-tagged producer. */
44+
public static final class State extends TableProducerState {
45+
/** Value identifying the function's owning schema. */
46+
public String tag;
47+
/** Whether the row has already been emitted. */
48+
public boolean done;
49+
50+
/** Required for continuation-state deserialization. */
51+
public State() {}
52+
53+
State(String tag) { this.tag = tag; }
54+
55+
@Override public void produceTick(OutputCollector out, CallContext ctx) {
56+
if (done) { out.finish(); return; }
57+
done = true;
58+
BatchUtil.emit(OUTPUT, 1, out, (root, rows, ignored) ->
59+
((VarCharVector) root.getVector("tag")).setSafe(0, new Text(tag)));
60+
}
61+
}
62+
63+
/** Main-schema implementation. */
64+
public static final class MainSchema extends Tagging {
65+
private static final FunctionSpec SPEC = FunctionSpec.builder(FUNCTION_NAME)
66+
.metadata(FunctionMetadata.describe(
67+
"Schema-disambiguation probe; the main-schema table producer")
68+
.withCategories("generator", "testing")
69+
.withExamples(List.of(new FunctionExample(
70+
"SELECT * FROM example.main.test_same_name_table",
71+
"One row tagged 'main'", null))))
72+
.build();
73+
74+
@Override public FunctionSpec spec() { return SPEC; }
75+
@Override String owningSchema() { return "main"; }
76+
}
77+
78+
/** Data-schema implementation. */
79+
public static final class DataSchema extends Tagging {
80+
private static final FunctionSpec SPEC = FunctionSpec.builder(FUNCTION_NAME)
81+
.metadata(FunctionMetadata.describe(
82+
"Schema-disambiguation probe; the data-schema table producer")
83+
.withCategories("generator", "testing")
84+
.withExamples(List.of(new FunctionExample(
85+
"SELECT * FROM example.data.test_same_name_table",
86+
"One row tagged 'data'", null))))
87+
.build();
88+
89+
@Override public FunctionSpec spec() { return SPEC; }
90+
@Override String owningSchema() { return "data"; }
91+
}
92+
}

0 commit comments

Comments
 (0)