@@ -37,7 +37,7 @@ pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "HASURA_BIGQUERY_SERVICE_KEY";
37
37
const CONFIGURATION_QUERY : & str = include_str ! ( "config2.sql" ) ;
38
38
const CONFIGURATION_JSONSCHEMA_FILENAME : & str = "schema.json" ;
39
39
40
- const CHARACTER_STRINGS : [ & str ; 4 ] = [ "char " , "text" , "varchar ", "string" ] ;
40
+ const CHARACTER_STRINGS : [ & str ; 3 ] = [ "character " , "text" , "string" ] ;
41
41
const UNICODE_CHARACTER_STRINGS : [ & str ; 3 ] = [ "nchar" , "ntext" , "nvarchar" ] ;
42
42
const CANNOT_COMPARE : [ & str ; 3 ] = [ "text" , "ntext" , "image" ] ;
43
43
const EXACT_NUMERICS : [ & str ; 9 ] = [
@@ -51,7 +51,7 @@ const EXACT_NUMERICS: [&str; 9] = [
51
51
"smallmoney" ,
52
52
"tinyint" ,
53
53
] ;
54
- const APPROX_NUMERICS : [ & str ; 2 ] = [ "float" , "real" ] ;
54
+ const APPROX_NUMERICS : [ & str ; 3 ] = [ "float" , "real" , "float64 "] ;
55
55
const NOT_COUNTABLE : [ & str ; 3 ] = [ "image" , "ntext" , "text" ] ;
56
56
const NOT_APPROX_COUNTABLE : [ & str ; 4 ] = [ "image" , "sql_variant" , "ntext" , "text" ] ;
57
57
@@ -682,7 +682,7 @@ fn get_aggregate_functions_for_type(
682
682
aggregate_functions. insert (
683
683
AggregateFunctionName :: new ( "COUNT" . into ( ) ) ,
684
684
database:: AggregateFunction {
685
- return_type : TypeName :: new ( "int " . to_string ( ) . into ( ) ) ,
685
+ return_type : TypeName :: new ( "bigint " . to_string ( ) . into ( ) ) ,
686
686
} ,
687
687
) ;
688
688
}
@@ -691,66 +691,67 @@ fn get_aggregate_functions_for_type(
691
691
&& ( EXACT_NUMERICS . contains ( & type_name. as_str ( ) )
692
692
|| APPROX_NUMERICS . contains ( & type_name. as_str ( ) )
693
693
|| CHARACTER_STRINGS . contains ( & type_name. as_str ( ) )
694
+ || type_name. as_str ( ) == "date"
694
695
|| type_name. as_str ( ) == "datetime"
695
- || type_name. as_str ( ) == "uniqueidentifier " )
696
+ || type_name. as_str ( ) == "uuid " )
696
697
{
697
698
aggregate_functions. insert (
698
699
AggregateFunctionName :: new ( "MIN" . into ( ) ) ,
699
700
database:: AggregateFunction {
700
- return_type : TypeName :: new ( type_name. to_string ( ) . into ( ) ) ,
701
+ return_type : TypeName :: new ( type_name. as_str ( ) . to_string ( ) . into ( ) ) ,
701
702
} ,
702
703
) ;
703
704
aggregate_functions. insert (
704
705
AggregateFunctionName :: new ( "MAX" . into ( ) ) ,
705
706
database:: AggregateFunction {
706
- return_type : TypeName :: new ( type_name. to_string ( ) . into ( ) ) ,
707
+ return_type : TypeName :: new ( type_name. as_str ( ) . to_string ( ) . into ( ) ) ,
707
708
} ,
708
709
) ;
709
710
}
710
711
711
- if type_name. as_str ( ) != "bit"
712
- && ( EXACT_NUMERICS . contains ( & type_name. as_str ( ) )
713
- || APPROX_NUMERICS . contains ( & type_name. as_str ( ) ) )
714
- {
715
- aggregate_functions. insert (
716
- AggregateFunctionName :: new ( "STDEV" . into ( ) ) ,
717
- database:: AggregateFunction {
718
- return_type : TypeName :: new ( "float" . to_string ( ) . into ( ) ) ,
719
- } ,
720
- ) ;
721
- aggregate_functions. insert (
722
- AggregateFunctionName :: new ( "STDEVP" . into ( ) ) ,
723
- database:: AggregateFunction {
724
- return_type : TypeName :: new ( "float" . to_string ( ) . into ( ) ) ,
725
- } ,
726
- ) ;
727
- aggregate_functions. insert (
728
- AggregateFunctionName :: new ( "VAR" . into ( ) ) ,
729
- database:: AggregateFunction {
730
- return_type : TypeName :: new ( "float" . to_string ( ) . into ( ) ) ,
731
- } ,
732
- ) ;
733
- aggregate_functions. insert (
734
- AggregateFunctionName :: new ( "VARP" . into ( ) ) ,
735
- database:: AggregateFunction {
736
- return_type : TypeName :: new ( "float" . to_string ( ) . into ( ) ) ,
737
- } ,
738
- ) ;
739
- }
712
+ // if type_name.as_str() != "bit"
713
+ // && (EXACT_NUMERICS.contains(&type_name.as_str())
714
+ // || APPROX_NUMERICS.contains(&type_name.as_str()))
715
+ // {
716
+ // aggregate_functions.insert(
717
+ // AggregateFunctionName::new("STDEV".into()),
718
+ // database::AggregateFunction {
719
+ // return_type: TypeName::new("float".to_string().into()),
720
+ // },
721
+ // );
722
+ // aggregate_functions.insert(
723
+ // AggregateFunctionName::new("STDEVP".into()),
724
+ // database::AggregateFunction {
725
+ // return_type: TypeName::new("float".to_string().into()),
726
+ // },
727
+ // );
728
+ // aggregate_functions.insert(
729
+ // AggregateFunctionName::new("VAR".into()),
730
+ // database::AggregateFunction {
731
+ // return_type: TypeName::new("float".to_string().into()),
732
+ // },
733
+ // );
734
+ // aggregate_functions.insert(
735
+ // AggregateFunctionName::new("VARP".into()),
736
+ // database::AggregateFunction {
737
+ // return_type: TypeName::new("float".to_string().into()),
738
+ // },
739
+ // );
740
+ // }
740
741
741
742
if let Some ( precise_return_type) = match type_name. as_str ( ) {
742
- "tinyint" => Some ( "int " ) ,
743
- "smallint" => Some ( "int " ) ,
744
- "int" => Some ( "int " ) ,
743
+ "tinyint" => Some ( "smallint " ) ,
744
+ "smallint" => Some ( "smallint " ) ,
745
+ "int" => Some ( "integer " ) ,
745
746
"bigint" => Some ( "bigint" ) ,
746
747
"decimal" => Some ( "decimal" ) ,
747
748
"money" => Some ( "money" ) ,
748
749
"smallmoney" => Some ( "money" ) ,
749
750
"float" => Some ( "float" ) ,
750
751
"real" => Some ( "float" ) ,
751
752
"int64" => Some ( "bigint" ) ,
752
- "int32" => Some ( "int " ) ,
753
- "int16" => Some ( "int " ) ,
753
+ "int32" => Some ( "integer " ) ,
754
+ "int16" => Some ( "smallint " ) ,
754
755
_ => None ,
755
756
} {
756
757
aggregate_functions. insert (
@@ -767,12 +768,12 @@ fn get_aggregate_functions_for_type(
767
768
) ;
768
769
} ;
769
770
770
- aggregate_functions. insert (
771
- AggregateFunctionName :: new ( "COUNT_BIG" . into ( ) ) ,
772
- database:: AggregateFunction {
773
- return_type : TypeName :: new ( "bigint" . to_string ( ) . into ( ) ) ,
774
- } ,
775
- ) ;
771
+ // aggregate_functions.insert(
772
+ // AggregateFunctionName::new("COUNT_BIG".into()),
773
+ // database::AggregateFunction {
774
+ // return_type: TypeName::new("bigint".to_string().into()),
775
+ // },
776
+ // );
776
777
777
778
aggregate_functions
778
779
}
@@ -787,14 +788,42 @@ fn get_scalar_types(type_names: &Vec<TypeItem>, schema_name: String) -> database
787
788
Some ( schema_name)
788
789
} ;
789
790
790
- for type_name in type_names {
791
+ for type_item in type_names {
792
+ let type_name = match type_item. name . as_str ( ) . to_lowercase ( ) . as_str ( ) {
793
+ "boolean" => "boolean" ,
794
+ "int" => "integer" ,
795
+ "int16" => "smallint" ,
796
+ "smallint" => "smallint" ,
797
+ "int32" => "integer" ,
798
+ "integer" => "integer" ,
799
+ "int64" => "bigint" ,
800
+ "bigint" => "bigint" ,
801
+ "numeric" => "numeric" ,
802
+ "float64" => "float" ,
803
+ "float" => "float" ,
804
+ "real" => "real" ,
805
+ "double precision" => "double precision" ,
806
+ "text" => "text" ,
807
+ "string" => "string" ,
808
+ "character" => "character" ,
809
+ "json" => "json" ,
810
+ "jsonb" => "jsonb" ,
811
+ "date" => "date" ,
812
+ "time with time zone" => "time with time zone" ,
813
+ "time without time zone" => "time without time zone" ,
814
+ "timestamp with time zone" => "timestamp with time zone" ,
815
+ "timestamp without time zone" => "timestamp without time zone" ,
816
+ "uuid" => "uuid" ,
817
+ _ => "any"
818
+ } ;
819
+ let type_name_scalar = ScalarTypeName :: new ( type_name. into ( ) ) ;
791
820
scalar_types. insert (
792
- type_name . name . clone ( ) ,
821
+ type_name_scalar . clone ( ) ,
793
822
database:: ScalarType {
794
- type_name : type_name . name . clone ( ) ,
823
+ type_name : type_name_scalar . clone ( ) ,
795
824
schema_name : schema. clone ( ) ,
796
- comparison_operators : get_comparison_operators_for_type ( & type_name . name ) ,
797
- aggregate_functions : get_aggregate_functions_for_type ( & type_name . name ) ,
825
+ comparison_operators : get_comparison_operators_for_type ( & type_name_scalar ) ,
826
+ aggregate_functions : get_aggregate_functions_for_type ( & type_name_scalar ) ,
798
827
description : None ,
799
828
type_representation : None ,
800
829
} ,
0 commit comments