Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions apps/interpreter/test/assets/broken-model.jv
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ pipeline CarsPipeline {
}

transform CarParser {
from r oftype Collection<text>;
from r oftype SheetRow;
to car oftype Car;

car: {
name: asText (r cellInColumn "name"),
mpg: asDecimal (r cellInColumn "mpg"),
cyl: asInteger (r cellInColumn 2),
disp: asDecimal (r cellInColumn 3),
hp: asInteger (r cellInColumn "hp"),
drat: asDecimal (r cellInColumn "drat"),
wt: asDecimal (r cellInColumn "wt"),
qsec: asDecimal (r cellInColumn "qsec"),
vs: asInteger (r cellInColumn "vs"),
am: asInteger (r cellInColumn "am"),
gear: asInteger (r cellInColumn "gear"),
carb: asInteger (r cellInColumn "carb")
name: asText (r . "name"),
mpg: asDecimal (r . "mpg"),
cyl: asInteger (r . 2),
disp: asDecimal (r . 3),
hp: asInteger (r . "hp"),
drat: asDecimal (r . "drat"),
wt: asDecimal (r . "wt"),
qsec: asDecimal (r . "qsec"),
vs: asInteger (r . "vs"),
am: asInteger (r . "am"),
gear: asInteger (r . "gear"),
carb: asInteger (r . "carb")
};
}

Expand Down
26 changes: 13 additions & 13 deletions example/cars.jv
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,22 @@ pipeline CarsPipeline {
}

transform CarParser {
from r oftype Collection<text>;
from r oftype SheetRow;
to car oftype Car;

car: {
name: asText (r cellInColumn "name"),
mpg: asDecimal (r cellInColumn "mpg"),
cyl: asInteger (r cellInColumn 2),
disp: asDecimal (r cellInColumn 3),
hp: asInteger (r cellInColumn "hp"),
drat: asDecimal (r cellInColumn "drat"),
wt: asDecimal (r cellInColumn "wt"),
qsec: asDecimal (r cellInColumn "qsec"),
vs: asInteger (r cellInColumn "vs"),
am: asInteger (r cellInColumn "am"),
gear: asInteger (r cellInColumn "gear"),
carb: asInteger (r cellInColumn "carb")
name: asText (r."name"),
mpg: asDecimal (r . "mpg"),
cyl: asInteger (r.2),
disp: asDecimal (r . 3),
hp: asInteger (r . "hp"),
drat: asDecimal (r . "drat"),
wt: asDecimal (r . "wt"),
qsec: asDecimal (r . "qsec"),
vs: asInteger (r . "vs"),
am: asInteger (r . "am"),
gear: asInteger (r . "gear"),
carb: asInteger (r . "carb")
};
}

Expand Down
36 changes: 18 additions & 18 deletions example/electric-vehicles.jv
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,27 @@ pipeline ElectricVehiclesPipeline {
}

transform ElectricVehicleParser {
from r oftype Collection<text>;
from r oftype SheetRow;
to ev oftype ElectricVehicle;

ev: {
vin: r cellInColumn "VIN (1-10)",
county: asText (r cellInColumn "County"),
city: asText (r cellInColumn "City"),
state: asText (r cellInColumn "State"),
postal: asText (r cellInColumn "Postal Code"),
modelYear: asInteger (r cellInColumn "Model Year"),
make: asText (r cellInColumn "Make"),
model: asText (r cellInColumn "Model"),
evType: asText (r cellInColumn "Electric Vehicle Type"),
cafvEligibility: asText (r cellInColumn "Clean Alternative Fuel Vehicle (CAFV) Eligibility"),
electricRange: asInteger (r cellInColumn "Electric Range"),
baseMSRP: asInteger (r cellInColumn "Base MSRP"),
legislativeDistrict: asText (r cellInColumn "LegislativeDistrict"),
dolID: asInteger (r cellInColumn "DOL Vehicle ID"),
location: asText (r cellInColumn "Vehicle Location"),
utility: asText (r cellInColumn "Electric Utility"),
censusTract: asText (r cellInColumn "2020 Census Tract"),
vin: r . "VIN (1-10)",
county: asText (r . "County"),
city: asText (r . "City"),
state: asText (r . "State"),
postal: asText (r . "Postal Code"),
modelYear: asInteger (r . "Model Year"),
make: asText (r . "Make"),
model: asText (r . "Model"),
evType: asText (r . "Electric Vehicle Type"),
cafvEligibility: asText (r . "Clean Alternative Fuel Vehicle (CAFV) Eligibility"),
electricRange: asInteger (r . "Electric Range"),
baseMSRP: asInteger (r . "Base MSRP"),
legislativeDistrict: asText (r . "LegislativeDistrict"),
dolID: asInteger (r . "DOL Vehicle ID"),
location: asText (r . "Vehicle Location"),
utility: asText (r . "Electric Utility"),
censusTract: asText (r . "2020 Census Tract"),
};
}

Expand Down
60 changes: 30 additions & 30 deletions example/gtfs-rt.jv
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ pipeline GtfsRTSimplePipeline {
property entityTripUpdateStopTimeUpdateDepartureTime oftype text;
}
transform TripUpdateParser {
from r oftype Collection<text>;
from r oftype SheetRow;
to tripUpdate oftype TripUpdate;

tripUpdate: {
headerGtfsRealtimeVersion: r cellInColumn "header.gtfs_realtime_version",
headerTimestamp: r cellInColumn "header.timestamp",
headerIncrementality: r cellInColumn "header.incrementality",
entityId: r cellInColumn "entity.id",
entityTripUpdateTripTripId: r cellInColumn "entity.trip_update.trip.trip_id",
entityTripUpdateTripRouteId: r cellInColumn "entity.trip_update.trip.route_id",
entityTripUpdateStopTimeUpdateStopSequence: r cellInColumn "entity.trip_update.stop_time_update.stop_sequence",
entityTripUpdateStopTimeUpdateStopId: r cellInColumn "entity.trip_update.stop_time_update.stop_id",
entityTripUpdateStopTimeUpdateArrivalTime: r cellInColumn "entity.trip_update.stop_time_update.arrival.time",
entityTripUpdateStopTimeUpdateDepartureTime: r cellInColumn "entity.trip_update.stop_time_update.departure.time",
headerGtfsRealtimeVersion: r . "header.gtfs_realtime_version",
headerTimestamp: r . "header.timestamp",
headerIncrementality: r . "header.incrementality",
entityId: r . "entity.id",
entityTripUpdateTripTripId: r . "entity.trip_update.trip.trip_id",
entityTripUpdateTripRouteId: r . "entity.trip_update.trip.route_id",
entityTripUpdateStopTimeUpdateStopSequence: r . "entity.trip_update.stop_time_update.stop_sequence",
entityTripUpdateStopTimeUpdateStopId: r . "entity.trip_update.stop_time_update.stop_id",
entityTripUpdateStopTimeUpdateArrivalTime: r . "entity.trip_update.stop_time_update.arrival.time",
entityTripUpdateStopTimeUpdateDepartureTime: r . "entity.trip_update.stop_time_update.departure.time",
};
}
block TripUpdateTableInterpreter oftype TableInterpreter {
Expand All @@ -107,20 +107,20 @@ pipeline GtfsRTSimplePipeline {
property entityVehiclePositionTimestamp oftype text;
}
transform VehiclePositionParser {
from r oftype Collection<text>;
from r oftype SheetRow;
to vehiclePosition oftype VehiclePosition;

vehiclePosition: {
headerGtfsRealtimeVersion: r cellInColumn "header.gtfs_realtime_version",
headerTimestamp: r cellInColumn "header.timestamp",
headerIncrementality: r cellInColumn "header.incrementality",
entityId: r cellInColumn "entity.id",
entityVehiclePositionVehicleDescriptorId: r cellInColumn "entity.vehicle_position.vehicle_descriptor.id",
entityVehiclePositionTripTripId: r cellInColumn "entity.vehicle_position.trip.trip_id",
entityVehiclePositionTripRouteId: r cellInColumn "entity.vehicle_position.trip.route_id",
entityVehiclePositionPositionLatitude: r cellInColumn "entity.vehicle_position.position.latitude",
entityVehiclePositionPositionLongitude: r cellInColumn "entity.vehicle_position.position.longitude",
entityVehiclePositionTimestamp: r cellInColumn "entity.vehicle_position.timestamp",
headerGtfsRealtimeVersion: r . "header.gtfs_realtime_version",
headerTimestamp: r . "header.timestamp",
headerIncrementality: r . "header.incrementality",
entityId: r . "entity.id",
entityVehiclePositionVehicleDescriptorId: r . "entity.vehicle_position.vehicle_descriptor.id",
entityVehiclePositionTripTripId: r . "entity.vehicle_position.trip.trip_id",
entityVehiclePositionTripRouteId: r . "entity.vehicle_position.trip.route_id",
entityVehiclePositionPositionLatitude: r . "entity.vehicle_position.position.latitude",
entityVehiclePositionPositionLongitude: r . "entity.vehicle_position.position.longitude",
entityVehiclePositionTimestamp: r . "entity.vehicle_position.timestamp",
};
}
block VehiclePositionTableInterpreter oftype TableInterpreter {
Expand All @@ -140,17 +140,17 @@ pipeline GtfsRTSimplePipeline {
property entityAlertDescriptionText oftype text;
}
transform AlertParser {
from r oftype Collection<text>;
from r oftype SheetRow;
to alert oftype Alert;

alert: {
headerGtfsRealtimeVersion: r cellInColumn "header.gtfs_realtime_version",
headerTimestamp: r cellInColumn "header.timestamp",
headerIncrementality: r cellInColumn "header.incrementality",
entityId: r cellInColumn "entity.id",
entityAlertInformedEntityRouteId: r cellInColumn "entity.alert.informed_entity.route_id",
entityAlertHeaderText: r cellInColumn "entity.alert.header_text",
entityAlertDescriptionText: r cellInColumn "entity.alert.description_text",
headerGtfsRealtimeVersion: r . "header.gtfs_realtime_version",
headerTimestamp: r . "header.timestamp",
headerIncrementality: r . "header.incrementality",
entityId: r . "entity.id",
entityAlertInformedEntityRouteId: r . "entity.alert.informed_entity.route_id",
entityAlertHeaderText: r . "entity.alert.header_text",
entityAlertDescriptionText: r . "entity.alert.description_text",
};
}
block AlertTableInterpreter oftype TableInterpreter {
Expand Down
7 changes: 4 additions & 3 deletions libs/execution/src/lib/transforms/transform-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { strict as assert } from 'assert';

import {
ERROR_TYPEGUARD,
onlyElementOrUndefined,
type InternalErrorValueRepresentation,
type InternalValidValueRepresentation,
InvalidValue,
Expand Down Expand Up @@ -64,9 +65,9 @@ export class TransformExecutor {

getOutputAssignment(): TransformOutputAssignment {
const outputAssignments = this.transform.body.outputAssignments;
assert(outputAssignments.length === 1);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return outputAssignments[0]!;
const outputAssignment = onlyElementOrUndefined(outputAssignments);
assert(outputAssignment !== undefined);
return outputAssignment;
}

executeTransform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ class InternalRepresentationParserVisitor extends ValueTypeVisitor<
`Cannot parse valuetype definitions into internal values`,
);
}

override visitSheetRow(): InvalidValue {
return new InvalidValue(`Cannot parse sheet rows into internal values`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { strict as assert } from 'assert';

import {
type SheetRowValueType,
type AtomicValueType,
type BooleanValuetype,
type CellRangeValuetype,
Expand Down Expand Up @@ -130,6 +131,10 @@ class ValueRepresentationValidityVisitor extends ValueTypeVisitor<boolean> {
return this.isValidForPrimitiveValuetype(valueType);
}

override visitSheetRow(valueType: SheetRowValueType): boolean {
return this.isValidForPrimitiveValuetype(valueType);
}

override visitTransform(valueType: TransformValuetype): boolean {
return this.isValidForPrimitiveValuetype(valueType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export class SQLColumnTypeVisitor extends ValueTypeVisitor<string> {
);
}

override visitSheetRow(): string {
throw new Error(
'No visit implementation given for sheet rows. Cannot be the type of a column.',
);
}

override visitTransform(): string {
throw new Error(
'No visit implementation given for transforms. Cannot be the type of a column.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ export class SQLValueRepresentationVisitor extends ValueTypeVisitor<
);
}

override visitSheetRow(): (
value: InternalValidValueRepresentation | InternalErrorValueRepresentation,
) => string {
throw new Error(
'No visit implementation given for sheet row. Cannot be the type of a column.',
);
}

override visitTransform(): (
value: InternalValidValueRepresentation | InternalErrorValueRepresentation,
) => string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline TestPipeline {


transform Parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to t oftype TestValueType;

t: { };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pipeline TestPipeline {
}

transform Parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to t oftype TestValueType;

t: { Index: asInteger (r cellInColumn "Index"), Name: r cellInColumn "Name", Flag: asBoolean (r cellInColumn "Flag") };
t: { Index: asInteger (r . "Index"), Name: r . "Name", Flag: asBoolean (r . "Flag") };
}

block TestBlock oftype TableInterpreter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pipeline TestPipeline {
}

transform Parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to t oftype TestValueType;

t: { index: asInteger (r cellInColumn "index"), name: r cellInColumn "name", flag: asBoolean (r cellInColumn "flag") };
t: { index: asInteger (r . "index"), name: r . "name", flag: asBoolean (r . "flag") };
}

block TestBlock oftype TableInterpreter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pipeline TestPipeline {
}

transform Parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to t oftype TestValueType;

t: { index: asInteger (r cellInColumn 0), name: r cellInColumn 1, flag:
asBoolean (r cellInColumn 2) };
t: { index: asInteger (r . 0), name: r . 1, flag:
asBoolean (r . 2) };
}

block TestBlock oftype TableInterpreter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pipeline TestPipeline {
}

transform Parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to t oftype TestValueType;

t: { index: asInteger (r cellInColumn "index"), name: r cellInColumn "name", flag: asBoolean (r cellInColumn "flag") };
t: { index: asInteger (r . "index"), name: r . "name", flag: asBoolean (r . "flag") };
}

block TestBlock oftype TableInterpreter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pipeline TestPipeline {
}

transform Parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to t oftype TestValueType;

t: { index: asInteger (r cellInColumn 0), name: r cellInColumn 1, flag:
asBoolean (r cellInColumn 2) };
t: { index: asInteger (r . 0), name: r . 1, flag:
asBoolean (r . 2) };
}

block TestBlock oftype TableInterpreter {
Expand Down
4 changes: 2 additions & 2 deletions libs/interpreter-lib/test/assets/graph/composite-block.jv
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pipeline CarsPipeline {
}

transform parser {
from r oftype Collection<text>;
from r oftype SheetRow;
to y oftype CarName;
y: { name: asText (r cellInColumn "name") };
y: { name: asText (r . "name") };
}

block CarsTableInterpreter oftype TableInterpreter {
Expand Down
Loading