Fix aggregates for comparable types in BigQuery

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3211
GitOrigin-RevId: 1a63b0835fc5af687f6caca187968edc9efbb821
This commit is contained in:
Kirill Zaborsky 2021-12-30 12:59:53 +03:00 committed by hasura-bot
parent 549a5a31f0
commit a2bf2fdc8f
3 changed files with 123 additions and 42 deletions

View File

@ -11,6 +11,7 @@
- server: extend support for insert mutations to tables without primary key constraint in a MSSQL backend
- cli: migrate and seed subcommands has an option in prompt to choose and apply operation on all available databases
- server: fix parsing FLOAT64s in scientific notation and non-finite ones in BigQuery
- server: extend support for the `min`/`max` aggregates to all comparable types in BigQuery
## v2.1.1

View File

@ -869,12 +869,25 @@ parseScalarValue scalarType jValue = case scalarType of
parseJValue :: (J.FromJSON a) => J.Value -> Either QErr a
parseJValue = runAesonParser J.parseJSON
-- see comparable BigQuery data types in
-- https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
-- in practice only Geography data type is not comparable
-- as ARRAY isn't a scalar type in the backend
isComparableType, isNumType :: ScalarType -> Bool
-- TODO: What does this mean?
isComparableType = \case
BoolScalarType -> True
StringScalarType -> True
BytesScalarType -> True
_ -> False
IntegerScalarType -> True
FloatScalarType -> True
BoolScalarType -> True
TimestampScalarType -> True
DateScalarType -> True
TimeScalarType -> True
DatetimeScalarType -> True
GeographyScalarType -> False
DecimalScalarType -> True
BigDecimalScalarType -> True
StructScalarType -> True
isNumType =
\case
StringScalarType -> False

View File

@ -1,41 +1,108 @@
description: Simple GraphQL object query on author
url: /v1/graphql
status: 200
response:
data:
hasura_test_all_types:
- string: STRING
bytes: AAECAwQF
integer: '1'
float: '1.0'
special_floats:
- '1.23E23'
- '-Infinity'
- 'NaN'
numeric: '1'
bignumeric: '1'
boolean: true
timestamp: '2008-12-25T07:30:00Z'
date: '2000-12-30'
time: 07:30:00
datetime: '1998-10-18T13:45:55'
geography: POINT(1 1)
query:
query: |
query {
hasura_test_all_types {
string
bytes
integer
float
- description: Simple GraphQL select of all types
url: /v1/graphql
status: 200
response:
data:
hasura_test_all_types:
- string: STRING
bytes: AAECAwQF
integer: '1'
float: '1.0'
special_floats:
- '1.23E23'
- '-Infinity'
- 'NaN'
numeric: '1'
bignumeric: '1'
boolean: true
timestamp: '2008-12-25T07:30:00Z'
date: '2000-12-30'
time: 07:30:00
datetime: '1998-10-18T13:45:55'
geography: POINT(1 1)
query:
query: |
query {
hasura_test_all_types {
string
bytes
integer
float
special_floats
numeric
bignumeric
boolean
timestamp
date
time
datetime
geography
numeric
bignumeric
boolean
timestamp
date
time
datetime
geography
}
}
}
- description: Simple GraphQL aggregate select (min/max) of all comparable types
url: /v1/graphql
status: 200
response:
data:
hasura_test_all_types_aggregate:
aggregate:
max:
string: STRING
bytes: AAECAwQF
integer: '1'
float: '1.0'
numeric: '1'
bignumeric: '1'
boolean: true
timestamp: '2008-12-25T07:30:00Z'
date: '2000-12-30'
time: '07:30:00'
datetime: '1998-10-18T13:45:55'
min:
string: STRING
bytes: AAECAwQF
integer: '1'
float: '1.0'
numeric: '1'
bignumeric: '1'
boolean: true
timestamp: '2008-12-25T07:30:00Z'
date: '2000-12-30'
time: '07:30:00'
datetime: '1998-10-18T13:45:55'
query:
query: |
query {
hasura_test_all_types_aggregate {
aggregate {
max {
string
bytes
integer
float
numeric
bignumeric
boolean
timestamp
date
time
datetime
}
min {
string
bytes
integer
float
numeric
bignumeric
boolean
timestamp
date
time
datetime
}
}
}
}