Skip to content

Commit

Permalink
Fix UInt* inferred type mapping (#609)
Browse files Browse the repository at this point in the history
There's been a bug in case sensitivity - `UInt8` from ClickHouse has
defaulted to `text` field in our case.



I'm letting unsigned integers being just integers in ES response for
now. We could also make these `unsigned_long`s...

The inconsistency here is that we currently translate integers from CH
to longs in ES.
**So perhaps we should translate unsigned integers from CH to unsigned
longs in ES (and completely ditch the `integer` type)?** I'm open to
your suggestions here.
  • Loading branch information
mieciu authored Aug 5, 2024
1 parent 2eefe0e commit 1fedebe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quesma/clickhouse/type_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (c SchemaTypeAdapter) Convert(s string) (schema.Type, bool) {
return schema.TypeKeyword, true
case "Int", "Int8", "Int16", "Int32", "Int64":
return schema.TypeLong, true
case "Uint8", "Uint16", "Uint32", "Uint64", "Uint128", "Uint256":
return schema.TypeUnsignedLong, true
case "UInt8", "UInt16", "UInt32", "UInt64", "UInt128", "UInt256":
return schema.TypeInteger, true
case "Bool":
return schema.TypeBoolean, true
case "Float32", "Float64":
Expand Down
2 changes: 2 additions & 0 deletions quesma/quesma/functionality/field_capabilities/field_caps.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ func asElasticType(t schema.Type) string {
return elasticsearch_field_types.FieldTypeObject
case schema.TypePoint.Name:
return elasticsearch_field_types.FieldTypeGeoPoint
case schema.TypeInteger.Name:
return elasticsearch_field_types.FieldTypeInteger
default:
return elasticsearch_field_types.FieldTypeText
}
Expand Down
1 change: 1 addition & 0 deletions quesma/schema/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var (
// TODO add more and review existing
TypeText = Type{Name: "text", Properties: []TypeProperty{Searchable, FullText}}
TypeKeyword = Type{Name: "keyword", Properties: []TypeProperty{Searchable, Aggregatable}}
TypeInteger = Type{Name: "integer", Properties: []TypeProperty{Searchable, Aggregatable}}
TypeLong = Type{Name: "long", Properties: []TypeProperty{Searchable, Aggregatable}}
TypeUnsignedLong = Type{Name: "unsigned_long", Properties: []TypeProperty{Searchable, Aggregatable}}
TypeTimestamp = Type{Name: "timestamp", Properties: []TypeProperty{Searchable, Aggregatable}}
Expand Down

0 comments on commit 1fedebe

Please sign in to comment.