mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
Fix support for FLOAT64 in BigQuery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3209 GitOrigin-RevId: e7e981bcd043f0daab4b70344afb684484361758
This commit is contained in:
parent
393662c0e1
commit
234a5385cd
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
- server: extend support for insert mutations to tables without primary key constraint in a MSSQL backend
|
- 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
|
- 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
|
||||||
|
|
||||||
## v2.1.1
|
## v2.1.1
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ import Hasura.Prelude
|
|||||||
import Hasura.RQL.Types.Common qualified as RQL
|
import Hasura.RQL.Types.Common qualified as RQL
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Language.Haskell.TH.Syntax
|
import Language.Haskell.TH.Syntax
|
||||||
import Text.ParserCombinators.ReadP (readP_to_S)
|
import Text.ParserCombinators.ReadP (eof, readP_to_S)
|
||||||
|
|
||||||
data Select = Select
|
data Select = Select
|
||||||
{ selectTop :: !Top,
|
{ selectTop :: !Top,
|
||||||
@ -939,8 +939,16 @@ liberalDecimalParser fromText json = viaText <|> viaNumber
|
|||||||
text <- J.parseJSON json
|
text <- J.parseJSON json
|
||||||
-- Parsing scientific is safe; it doesn't normalise until we ask
|
-- Parsing scientific is safe; it doesn't normalise until we ask
|
||||||
-- it to.
|
-- it to.
|
||||||
case readP_to_S scientificP (T.unpack text) of
|
let -- See https://cloud.google.com/bigquery/docs/reference/standard-sql/conversion_functions#cast_as_floating_point
|
||||||
|
isNonFinite =
|
||||||
|
let noSign = case T.uncons text of
|
||||||
|
Just ('+', rest) -> rest
|
||||||
|
Just ('-', rest) -> rest
|
||||||
|
_ -> text
|
||||||
|
in T.toLower noSign `elem` ["nan", "infinity", "inf"]
|
||||||
|
case readP_to_S (scientificP <* eof) (T.unpack text) of
|
||||||
[_] -> pure (fromText text)
|
[_] -> pure (fromText text)
|
||||||
|
[] | isNonFinite -> pure (fromText text)
|
||||||
_ -> fail ("String containing decimal places is invalid: " ++ show text)
|
_ -> fail ("String containing decimal places is invalid: " ++ show text)
|
||||||
viaNumber = do
|
viaNumber = do
|
||||||
d <- J.parseJSON json
|
d <- J.parseJSON json
|
||||||
|
@ -11,6 +11,7 @@ args:
|
|||||||
`bytes` BYTES,
|
`bytes` BYTES,
|
||||||
`integer` INT64,
|
`integer` INT64,
|
||||||
`float` FLOAT64,
|
`float` FLOAT64,
|
||||||
|
`special_floats` ARRAY<FLOAT64>,
|
||||||
`numeric` NUMERIC,
|
`numeric` NUMERIC,
|
||||||
`bignumeric` BIGNUMERIC,
|
`bignumeric` BIGNUMERIC,
|
||||||
`boolean` BOOL,
|
`boolean` BOOL,
|
||||||
@ -39,6 +40,8 @@ args:
|
|||||||
CODE_POINTS_TO_BYTES([0,1,2,3,4,5]),
|
CODE_POINTS_TO_BYTES([0,1,2,3,4,5]),
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
-- IEEE_DIVIDE(x, 0) returns Infinity and Infinity/Infinity is NaN
|
||||||
|
[1.23e23, IEEE_DIVIDE(-1, 0), IEEE_DIVIDE(1, 0)/IEEE_DIVIDE(1, 0)],
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
true,
|
true,
|
||||||
|
@ -8,6 +8,10 @@ response:
|
|||||||
bytes: AAECAwQF
|
bytes: AAECAwQF
|
||||||
integer: '1'
|
integer: '1'
|
||||||
float: '1.0'
|
float: '1.0'
|
||||||
|
special_floats:
|
||||||
|
- '1.23E23'
|
||||||
|
- '-Infinity'
|
||||||
|
- 'NaN'
|
||||||
numeric: '1'
|
numeric: '1'
|
||||||
bignumeric: '1'
|
bignumeric: '1'
|
||||||
boolean: true
|
boolean: true
|
||||||
@ -24,6 +28,7 @@ query:
|
|||||||
bytes
|
bytes
|
||||||
integer
|
integer
|
||||||
float
|
float
|
||||||
|
special_floats
|
||||||
numeric
|
numeric
|
||||||
bignumeric
|
bignumeric
|
||||||
boolean
|
boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user