Skip to content

Commit

Permalink
Re-add GQLType remove CHType
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJoiner committed May 17, 2024
1 parent 9981dd3 commit 457a138
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 76 deletions.
46 changes: 9 additions & 37 deletions pkg/schema/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type SignalInfo struct {
GOName string
JSONName string
BaseGoType string
BaseCHType string
BaseGQLType string
Conversions []*ConversionInfo
Privileges []string
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func NewSignalInfo(record []string) *SignalInfo {
if baseType != "" {
// if this is not a branch type, we can convert it to default golang and clickhouse types
sig.BaseGoType = goTypeFromVSPEC(baseType)
sig.BaseCHType = chTypeFromVSPEC(baseType)
sig.BaseGQLType = gqlTypeFromVSPEC(baseType)
}
sig.GOName = goName(sig.Name)
sig.JSONName = JSONName(sig.Name)
Expand All @@ -115,9 +115,6 @@ func NewSignalInfo(record []string) *SignalInfo {

// MergeWithDefinition merges the signal with the definition information.
func (s *SignalInfo) MergeWithDefinition(definition *DefinitionInfo) {
if definition.ClickHouseType != "" {
s.BaseCHType = definition.ClickHouseType
}
if definition.GoType != "" {
s.BaseGoType = definition.GoType
}
Expand All @@ -143,12 +140,9 @@ func (s *SignalInfo) GOType() string {
return s.BaseGoType
}

// CHType returns the clickhouse type of the signal.
func (s *SignalInfo) CHType() string {
if s.IsArray {
return "Array(" + s.BaseCHType + ")"
}
return s.BaseCHType
// GQLType returns the graphql type of the signal.
func (s *SignalInfo) GQLType() string {
return s.BaseGQLType
}

func goName(name string) string {
Expand Down Expand Up @@ -180,33 +174,11 @@ func goTypeFromVSPEC(dataType string) string {
}
}

// chTypeFromVSPEC converts vspec type to clickhouse types.
func chTypeFromVSPEC(baseType string) string {
// gqlTypeFromVSPEC converts vspec type to graphql types.
func gqlTypeFromVSPEC(baseType string) string {
switch baseType {
case "uint8":
return "UInt8"
case "int8":
return "Int8"
case "uint16":
return "UInt16"
case "int16":
return "Int16"
case "uint32":
return "UInt32"
case "int32":
return "Int32"
case "uint64":
return "UInt64"
case "int64":
return "Int64"
case "string":
return "String"
case "boolean":
return "Bool"
case "float":
return "Float32"
case "double":
return "Float64"
case "uint8", "int8", "uint16", "int16", "uint32", "int32", "float", "double", "uint64", "int64", "Boolean":
return "Float"
default:
return "String"
}
Expand Down
40 changes: 1 addition & 39 deletions pkg/schema/spec/definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
# isArray: Whether the field is an array or not
# if null then the value is inferred from the vspec definition
isArray: null

# clickHouseType: The type to use for ClickHouse ase.
#if empty then the type is inferred from the vspec definition
clickHouseType: ""


# goType: The type to use for Golang struct.
# if empty then the type is inferred from the vspec definition
goType: ""
Expand All @@ -31,7 +27,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Chassis.Axle.Row1.Wheel.Right.Tire.Pressure
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -42,7 +37,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Chassis.Axle.Row2.Wheel.Left.Tire.Pressure
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -53,7 +47,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Chassis.Axle.Row2.Wheel.Right.Tire.Pressure
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -64,7 +57,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.CurrentLocation.Altitude
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -75,7 +67,6 @@
- VEHICLE_ALL_TIME_LOCATION
- vspecName: Vehicle.CurrentLocation.Latitude
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -86,7 +77,6 @@
- VEHICLE_ALL_TIME_LOCATION
- vspecName: Vehicle.CurrentLocation.Longitude
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -111,7 +101,6 @@
- VEHICLE_ALL_TIME_LOCATION
- vspecName: Vehicle.Exterior.AirTemperature
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -122,7 +111,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.LowVoltageBattery.CurrentVoltage
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -133,7 +121,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.OBD.BarometricPressure
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -144,7 +131,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.OBD.EngineLoad
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -155,7 +141,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.OBD.IntakeTemp
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -166,7 +151,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.OBD.RunTime
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -177,7 +161,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.CombustionEngine.ECT
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -188,7 +171,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.CombustionEngine.EngineOilLevel
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -199,7 +181,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.CombustionEngine.Speed
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -210,7 +191,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.CombustionEngine.TPS
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -221,7 +201,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.FuelSystem.AbsoluteLevel
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -232,7 +211,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.FuelSystem.SupportedFuelTypes
isArray: false
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -243,7 +221,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.Range
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -254,7 +231,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.TractionBattery.Charging.ChargeLimit
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -265,7 +241,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.TractionBattery.Charging.IsCharging
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -276,7 +251,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.TractionBattery.GrossCapacity
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -287,7 +261,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.TractionBattery.StateOfCharge.Current
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -298,7 +271,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.Transmission.TravelledDistance
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -309,7 +281,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.Type
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -320,7 +291,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Speed
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -331,7 +301,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.VehicleIdentification.Brand
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -342,7 +311,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.VehicleIdentification.Model
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -353,7 +321,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.VehicleIdentification.Year
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -364,7 +331,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.Powertrain.CombustionEngine.MAF
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -375,7 +341,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.DIMO.Aftermarket.HDOP
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -386,7 +351,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.DIMO.Aftermarket.NSAT
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -397,7 +361,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.DIMO.Aftermarket.WPAState
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand All @@ -408,7 +371,6 @@
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.DIMO.Aftermarket.SSID
isArray: null
clickHouseType: ""
goType: ""
gqlType: ""
conversions:
Expand Down

0 comments on commit 457a138

Please sign in to comment.