@quillsql/react 2.13.22 → 2.13.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ChartBuilder.d.ts +7 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +36 -19
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +183 -233
- package/dist/cjs/SQLEditor.js +12 -10
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.d.ts +2 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +5 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +1 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +1 -2
- package/dist/cjs/components/ReportBuilder/convert.d.ts +1 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +31 -4
- package/dist/cjs/components/ReportBuilder/util.js +1 -1
- package/dist/cjs/components/UiComponents.d.ts +3 -2
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +6 -3
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +921 -1604
- package/dist/cjs/utils/astProcessing.d.ts +1 -1
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +4 -2
- package/dist/cjs/utils/constants.d.ts.map +1 -1
- package/dist/cjs/utils/constants.js +2 -2
- package/dist/cjs/utils/logging.js +1 -1
- package/dist/cjs/utils/pivotConstructor.js +2 -2
- package/dist/cjs/utils/queryConstructor.js +2 -2
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +1 -1
- package/dist/esm/ChartBuilder.d.ts +7 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +36 -19
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +190 -238
- package/dist/esm/SQLEditor.js +12 -10
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.d.ts +2 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +5 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +1 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +1 -2
- package/dist/esm/components/ReportBuilder/convert.d.ts +1 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +31 -4
- package/dist/esm/components/ReportBuilder/util.js +1 -1
- package/dist/esm/components/UiComponents.d.ts +3 -2
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +6 -3
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +921 -1604
- package/dist/esm/utils/astProcessing.d.ts +1 -1
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +4 -2
- package/dist/esm/utils/constants.d.ts.map +1 -1
- package/dist/esm/utils/constants.js +2 -2
- package/dist/esm/utils/logging.js +1 -1
- package/dist/esm/utils/pivotConstructor.js +2 -2
- package/dist/esm/utils/queryConstructor.js +2 -2
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +1 -1
- package/package.json +1 -1
|
@@ -611,6 +611,7 @@ const queryPatterns = [
|
|
|
611
611
|
},
|
|
612
612
|
unit: function (astWhere) {
|
|
613
613
|
return (astWhere.right?.args?.value[0]?.column?.expr?.value?.toLowerCase() ??
|
|
614
|
+
astWhere.right?.args?.value[0]?.column.toLowerCase() ??
|
|
614
615
|
null);
|
|
615
616
|
},
|
|
616
617
|
ast: {
|
|
@@ -646,12 +647,7 @@ const queryPatterns = [
|
|
|
646
647
|
left: {
|
|
647
648
|
type: 'column_ref',
|
|
648
649
|
table: null,
|
|
649
|
-
column:
|
|
650
|
-
expr: {
|
|
651
|
-
type: 'default',
|
|
652
|
-
value: 'transaction_date',
|
|
653
|
-
},
|
|
654
|
-
},
|
|
650
|
+
column: 'transaction_date',
|
|
655
651
|
},
|
|
656
652
|
right: {
|
|
657
653
|
type: 'function',
|
|
@@ -669,12 +665,7 @@ const queryPatterns = [
|
|
|
669
665
|
{
|
|
670
666
|
type: 'column_ref',
|
|
671
667
|
table: null,
|
|
672
|
-
column:
|
|
673
|
-
expr: {
|
|
674
|
-
type: 'default',
|
|
675
|
-
value: 'DAY',
|
|
676
|
-
},
|
|
677
|
-
},
|
|
668
|
+
column: 'DAY',
|
|
678
669
|
},
|
|
679
670
|
{
|
|
680
671
|
type: 'number',
|
|
@@ -685,7 +676,7 @@ const queryPatterns = [
|
|
|
685
676
|
name: {
|
|
686
677
|
name: [
|
|
687
678
|
{
|
|
688
|
-
type: '
|
|
679
|
+
type: 'default',
|
|
689
680
|
value: 'CURRENT_DATE',
|
|
690
681
|
},
|
|
691
682
|
],
|
|
@@ -702,6 +693,7 @@ const queryPatterns = [
|
|
|
702
693
|
},
|
|
703
694
|
groupby: null,
|
|
704
695
|
having: null,
|
|
696
|
+
qualify: null,
|
|
705
697
|
orderby: null,
|
|
706
698
|
limit: {
|
|
707
699
|
seperator: '',
|
|
@@ -773,12 +765,7 @@ const queryPatterns = [
|
|
|
773
765
|
left: {
|
|
774
766
|
type: 'column_ref',
|
|
775
767
|
table: null,
|
|
776
|
-
column:
|
|
777
|
-
expr: {
|
|
778
|
-
type: 'default',
|
|
779
|
-
value: 'transaction_date',
|
|
780
|
-
},
|
|
781
|
-
},
|
|
768
|
+
column: 'transaction_date',
|
|
782
769
|
},
|
|
783
770
|
right: {
|
|
784
771
|
type: 'binary_expr',
|
|
@@ -788,7 +775,7 @@ const queryPatterns = [
|
|
|
788
775
|
name: {
|
|
789
776
|
name: [
|
|
790
777
|
{
|
|
791
|
-
type: '
|
|
778
|
+
type: 'default',
|
|
792
779
|
value: 'CURRENT_DATE',
|
|
793
780
|
},
|
|
794
781
|
],
|
|
@@ -815,19 +802,14 @@ const queryPatterns = [
|
|
|
815
802
|
left: {
|
|
816
803
|
type: 'column_ref',
|
|
817
804
|
table: null,
|
|
818
|
-
column:
|
|
819
|
-
expr: {
|
|
820
|
-
type: 'default',
|
|
821
|
-
value: 'transaction_date',
|
|
822
|
-
},
|
|
823
|
-
},
|
|
805
|
+
column: 'transaction_date',
|
|
824
806
|
},
|
|
825
807
|
right: {
|
|
826
808
|
type: 'function',
|
|
827
809
|
name: {
|
|
828
810
|
name: [
|
|
829
811
|
{
|
|
830
|
-
type: '
|
|
812
|
+
type: 'default',
|
|
831
813
|
value: 'CURRENT_DATE',
|
|
832
814
|
},
|
|
833
815
|
],
|
|
@@ -842,6 +824,7 @@ const queryPatterns = [
|
|
|
842
824
|
},
|
|
843
825
|
groupby: null,
|
|
844
826
|
having: null,
|
|
827
|
+
qualify: null,
|
|
845
828
|
orderby: null,
|
|
846
829
|
limit: {
|
|
847
830
|
seperator: '',
|
|
@@ -855,7 +838,7 @@ const queryPatterns = [
|
|
|
855
838
|
SELECT *
|
|
856
839
|
FROM transactions
|
|
857
840
|
WHERE transaction_date >= DATEADD(DAY, -90, CURRENT_DATE())
|
|
858
|
-
AND transaction_date <= CURRENT_DATE()
|
|
841
|
+
AND transaction_date <= CURRENT_DATE()
|
|
859
842
|
`,
|
|
860
843
|
value: function (astWhere) {
|
|
861
844
|
return astWhere.left?.right?.args?.value[1]?.value
|
|
@@ -864,6 +847,7 @@ const queryPatterns = [
|
|
|
864
847
|
},
|
|
865
848
|
unit: function (astWhere) {
|
|
866
849
|
return (astWhere.left?.right?.args?.value[0]?.column?.expr?.value?.toLowerCase() ??
|
|
850
|
+
astWhere.left?.right?.args?.value[0]?.column?.toLowerCase() ??
|
|
867
851
|
null);
|
|
868
852
|
},
|
|
869
853
|
ast: {
|
|
@@ -902,12 +886,7 @@ const queryPatterns = [
|
|
|
902
886
|
left: {
|
|
903
887
|
type: 'column_ref',
|
|
904
888
|
table: null,
|
|
905
|
-
column:
|
|
906
|
-
expr: {
|
|
907
|
-
type: 'default',
|
|
908
|
-
value: 'transaction_date',
|
|
909
|
-
},
|
|
910
|
-
},
|
|
889
|
+
column: 'transaction_date',
|
|
911
890
|
},
|
|
912
891
|
right: {
|
|
913
892
|
type: 'function',
|
|
@@ -925,12 +904,7 @@ const queryPatterns = [
|
|
|
925
904
|
{
|
|
926
905
|
type: 'column_ref',
|
|
927
906
|
table: null,
|
|
928
|
-
column:
|
|
929
|
-
expr: {
|
|
930
|
-
type: 'default',
|
|
931
|
-
value: 'DAY',
|
|
932
|
-
},
|
|
933
|
-
},
|
|
907
|
+
column: 'DAY',
|
|
934
908
|
},
|
|
935
909
|
{
|
|
936
910
|
type: 'number',
|
|
@@ -941,7 +915,7 @@ const queryPatterns = [
|
|
|
941
915
|
name: {
|
|
942
916
|
name: [
|
|
943
917
|
{
|
|
944
|
-
type: '
|
|
918
|
+
type: 'default',
|
|
945
919
|
value: 'CURRENT_DATE',
|
|
946
920
|
},
|
|
947
921
|
],
|
|
@@ -962,19 +936,14 @@ const queryPatterns = [
|
|
|
962
936
|
left: {
|
|
963
937
|
type: 'column_ref',
|
|
964
938
|
table: null,
|
|
965
|
-
column:
|
|
966
|
-
expr: {
|
|
967
|
-
type: 'default',
|
|
968
|
-
value: 'transaction_date',
|
|
969
|
-
},
|
|
970
|
-
},
|
|
939
|
+
column: 'transaction_date',
|
|
971
940
|
},
|
|
972
941
|
right: {
|
|
973
942
|
type: 'function',
|
|
974
943
|
name: {
|
|
975
944
|
name: [
|
|
976
945
|
{
|
|
977
|
-
type: '
|
|
946
|
+
type: 'default',
|
|
978
947
|
value: 'CURRENT_DATE',
|
|
979
948
|
},
|
|
980
949
|
],
|
|
@@ -989,6 +958,7 @@ const queryPatterns = [
|
|
|
989
958
|
},
|
|
990
959
|
groupby: null,
|
|
991
960
|
having: null,
|
|
961
|
+
qualify: null,
|
|
992
962
|
orderby: null,
|
|
993
963
|
limit: {
|
|
994
964
|
seperator: '',
|
|
@@ -1032,7 +1002,7 @@ const queryPatterns = [
|
|
|
1032
1002
|
from: [
|
|
1033
1003
|
{
|
|
1034
1004
|
db: null,
|
|
1035
|
-
table: '
|
|
1005
|
+
table: 'transactions',
|
|
1036
1006
|
as: null,
|
|
1037
1007
|
},
|
|
1038
1008
|
],
|
|
@@ -1057,21 +1027,15 @@ const queryPatterns = [
|
|
|
1057
1027
|
value: 'year',
|
|
1058
1028
|
},
|
|
1059
1029
|
{
|
|
1060
|
-
type: '
|
|
1061
|
-
|
|
1062
|
-
column: {
|
|
1063
|
-
expr: {
|
|
1064
|
-
type: 'double_quote_string',
|
|
1065
|
-
value: 'CREATED_AT',
|
|
1066
|
-
},
|
|
1067
|
-
},
|
|
1030
|
+
type: 'double_quote_string',
|
|
1031
|
+
value: 'CREATED_AT',
|
|
1068
1032
|
},
|
|
1069
1033
|
{
|
|
1070
1034
|
type: 'function',
|
|
1071
1035
|
name: {
|
|
1072
1036
|
name: [
|
|
1073
1037
|
{
|
|
1074
|
-
type: '
|
|
1038
|
+
type: 'default',
|
|
1075
1039
|
value: 'CURRENT_DATE',
|
|
1076
1040
|
},
|
|
1077
1041
|
],
|
|
@@ -1092,7 +1056,93 @@ const queryPatterns = [
|
|
|
1092
1056
|
},
|
|
1093
1057
|
groupby: null,
|
|
1094
1058
|
having: null,
|
|
1059
|
+
qualify: null,
|
|
1060
|
+
orderby: null,
|
|
1061
|
+
limit: {
|
|
1062
|
+
seperator: '',
|
|
1063
|
+
value: [],
|
|
1064
|
+
},
|
|
1065
|
+
window: null,
|
|
1066
|
+
},
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
query: `
|
|
1070
|
+
SELECT *
|
|
1071
|
+
FROM transactions
|
|
1072
|
+
WHERE "CREATED_AT" >= CURRENT_DATE() - 90
|
|
1073
|
+
`,
|
|
1074
|
+
value: function (astWhere) {
|
|
1075
|
+
return astWhere.right?.right?.value ?? null;
|
|
1076
|
+
},
|
|
1077
|
+
unit: function () {
|
|
1078
|
+
return 'day';
|
|
1079
|
+
},
|
|
1080
|
+
ast: {
|
|
1081
|
+
with: null,
|
|
1082
|
+
type: 'select',
|
|
1083
|
+
options: null,
|
|
1084
|
+
distinct: {
|
|
1085
|
+
type: null,
|
|
1086
|
+
},
|
|
1087
|
+
columns: [
|
|
1088
|
+
{
|
|
1089
|
+
expr: {
|
|
1090
|
+
type: 'column_ref',
|
|
1091
|
+
table: null,
|
|
1092
|
+
column: '*',
|
|
1093
|
+
suffix: null,
|
|
1094
|
+
},
|
|
1095
|
+
as: null,
|
|
1096
|
+
},
|
|
1097
|
+
],
|
|
1098
|
+
into: {
|
|
1099
|
+
position: null,
|
|
1100
|
+
},
|
|
1101
|
+
from: [
|
|
1102
|
+
{
|
|
1103
|
+
db: null,
|
|
1104
|
+
table: 'transactions',
|
|
1105
|
+
as: null,
|
|
1106
|
+
operator: null,
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
where: {
|
|
1110
|
+
type: 'binary_expr',
|
|
1111
|
+
operator: '>=',
|
|
1112
|
+
left: {
|
|
1113
|
+
type: 'double_quote_string',
|
|
1114
|
+
value: 'CREATED_AT',
|
|
1115
|
+
},
|
|
1116
|
+
right: {
|
|
1117
|
+
type: 'binary_expr',
|
|
1118
|
+
operator: '-',
|
|
1119
|
+
left: {
|
|
1120
|
+
type: 'function',
|
|
1121
|
+
name: {
|
|
1122
|
+
name: [
|
|
1123
|
+
{
|
|
1124
|
+
type: 'default',
|
|
1125
|
+
value: 'CURRENT_DATE',
|
|
1126
|
+
},
|
|
1127
|
+
],
|
|
1128
|
+
},
|
|
1129
|
+
args: {
|
|
1130
|
+
type: 'expr_list',
|
|
1131
|
+
value: [],
|
|
1132
|
+
},
|
|
1133
|
+
over: null,
|
|
1134
|
+
},
|
|
1135
|
+
right: {
|
|
1136
|
+
type: 'number',
|
|
1137
|
+
value: 90,
|
|
1138
|
+
},
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
groupby: null,
|
|
1142
|
+
having: null,
|
|
1143
|
+
qualify: null,
|
|
1095
1144
|
orderby: null,
|
|
1145
|
+
top: null,
|
|
1096
1146
|
limit: {
|
|
1097
1147
|
seperator: '',
|
|
1098
1148
|
value: [],
|
|
@@ -1204,7 +1254,7 @@ const queryPatterns = [
|
|
|
1204
1254
|
WHERE transaction_date >= TIMESTAMP(DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY))
|
|
1205
1255
|
`,
|
|
1206
1256
|
value: function (astWhere) {
|
|
1207
|
-
return (astWhere.right?.args?.value[0]?.args?.value[1]?.expr?.value ??
|
|
1257
|
+
return (Math.abs(astWhere.right?.args?.value[0]?.args?.value[1]?.expr?.value) ?? // When DATE_ADD
|
|
1208
1258
|
null);
|
|
1209
1259
|
},
|
|
1210
1260
|
unit: function (astWhere) {
|
|
@@ -2758,12 +2808,7 @@ const queryPatterns = [
|
|
|
2758
2808
|
{
|
|
2759
2809
|
type: 'column_ref',
|
|
2760
2810
|
table: null,
|
|
2761
|
-
column:
|
|
2762
|
-
expr: {
|
|
2763
|
-
type: 'default',
|
|
2764
|
-
value: 'created_at',
|
|
2765
|
-
},
|
|
2766
|
-
},
|
|
2811
|
+
column: 'created_at',
|
|
2767
2812
|
},
|
|
2768
2813
|
],
|
|
2769
2814
|
},
|
|
@@ -2790,7 +2835,7 @@ const queryPatterns = [
|
|
|
2790
2835
|
name: {
|
|
2791
2836
|
name: [
|
|
2792
2837
|
{
|
|
2793
|
-
type: '
|
|
2838
|
+
type: 'default',
|
|
2794
2839
|
value: 'CURRENT_TIMESTAMP',
|
|
2795
2840
|
},
|
|
2796
2841
|
],
|
|
@@ -2807,6 +2852,7 @@ const queryPatterns = [
|
|
|
2807
2852
|
},
|
|
2808
2853
|
groupby: null,
|
|
2809
2854
|
having: null,
|
|
2855
|
+
qualify: null,
|
|
2810
2856
|
orderby: null,
|
|
2811
2857
|
limit: {
|
|
2812
2858
|
seperator: '',
|
|
@@ -2815,24 +2861,39 @@ const queryPatterns = [
|
|
|
2815
2861
|
window: null,
|
|
2816
2862
|
},
|
|
2817
2863
|
},
|
|
2818
|
-
],
|
|
2819
|
-
bigquery: [
|
|
2820
2864
|
{
|
|
2821
2865
|
query: `
|
|
2822
|
-
SELECT * FROM transactions
|
|
2823
|
-
WHERE
|
|
2824
|
-
AND EXTRACT(MONTH FROM transaction_date) = EXTRACT(MONTH FROM CURRENT_DATE())
|
|
2866
|
+
SELECT * FROM transactions
|
|
2867
|
+
WHERE TO_CHAR(CREATED_AT, 'YYYY-MM') = TO_CHAR(CURRENT_DATE(), 'YYYY-MM')
|
|
2825
2868
|
`,
|
|
2826
2869
|
value: function () {
|
|
2827
2870
|
return 0;
|
|
2828
2871
|
},
|
|
2829
2872
|
unit: function (astWhere) {
|
|
2830
|
-
|
|
2873
|
+
const unit = astWhere.right?.args?.value?.[1]?.value ?? null;
|
|
2874
|
+
switch (unit) {
|
|
2875
|
+
case 'YYYY':
|
|
2876
|
+
return 'year';
|
|
2877
|
+
case 'YYYY-Q':
|
|
2878
|
+
return 'quarter';
|
|
2879
|
+
case 'YYYY-MM':
|
|
2880
|
+
return 'month';
|
|
2881
|
+
case 'YYYY-IW':
|
|
2882
|
+
return 'week';
|
|
2883
|
+
case 'YYYY-MM-DD':
|
|
2884
|
+
return 'day';
|
|
2885
|
+
case 'YYYY-MM-DD HH24':
|
|
2886
|
+
return 'hour';
|
|
2887
|
+
}
|
|
2888
|
+
return null;
|
|
2831
2889
|
},
|
|
2832
2890
|
ast: {
|
|
2891
|
+
with: null,
|
|
2833
2892
|
type: 'select',
|
|
2834
|
-
|
|
2835
|
-
distinct:
|
|
2893
|
+
options: null,
|
|
2894
|
+
distinct: {
|
|
2895
|
+
type: null,
|
|
2896
|
+
},
|
|
2836
2897
|
columns: [
|
|
2837
2898
|
{
|
|
2838
2899
|
expr: {
|
|
@@ -2843,74 +2904,58 @@ const queryPatterns = [
|
|
|
2843
2904
|
as: null,
|
|
2844
2905
|
},
|
|
2845
2906
|
],
|
|
2907
|
+
into: {
|
|
2908
|
+
position: null,
|
|
2909
|
+
},
|
|
2846
2910
|
from: [
|
|
2847
2911
|
{
|
|
2848
2912
|
db: null,
|
|
2849
2913
|
table: 'transactions',
|
|
2850
2914
|
as: null,
|
|
2851
|
-
operator: null,
|
|
2852
2915
|
},
|
|
2853
2916
|
],
|
|
2854
|
-
for_sys_time_as_of: null,
|
|
2855
2917
|
where: {
|
|
2856
2918
|
type: 'binary_expr',
|
|
2857
|
-
operator: '
|
|
2919
|
+
operator: '=',
|
|
2858
2920
|
left: {
|
|
2859
|
-
type: '
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2921
|
+
type: 'function',
|
|
2922
|
+
name: {
|
|
2923
|
+
name: [
|
|
2924
|
+
{
|
|
2925
|
+
type: 'default',
|
|
2926
|
+
value: 'TO_CHAR',
|
|
2927
|
+
},
|
|
2928
|
+
],
|
|
2929
|
+
},
|
|
2930
|
+
args: {
|
|
2931
|
+
type: 'expr_list',
|
|
2932
|
+
value: [
|
|
2933
|
+
{
|
|
2866
2934
|
type: 'column_ref',
|
|
2867
2935
|
table: null,
|
|
2868
|
-
column: '
|
|
2936
|
+
column: 'CREATED_AT',
|
|
2869
2937
|
},
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
type: 'extract',
|
|
2874
|
-
args: {
|
|
2875
|
-
field: 'YEAR',
|
|
2876
|
-
source: {
|
|
2877
|
-
type: 'function',
|
|
2878
|
-
name: {
|
|
2879
|
-
name: [
|
|
2880
|
-
{
|
|
2881
|
-
type: 'default',
|
|
2882
|
-
value: 'CURRENT_DATE',
|
|
2883
|
-
},
|
|
2884
|
-
],
|
|
2885
|
-
},
|
|
2886
|
-
args: {
|
|
2887
|
-
type: 'expr_list',
|
|
2888
|
-
value: [],
|
|
2889
|
-
},
|
|
2890
|
-
over: null,
|
|
2938
|
+
{
|
|
2939
|
+
type: 'single_quote_string',
|
|
2940
|
+
value: 'YYYY-MM',
|
|
2891
2941
|
},
|
|
2892
|
-
|
|
2942
|
+
],
|
|
2893
2943
|
},
|
|
2894
2944
|
},
|
|
2895
2945
|
right: {
|
|
2896
|
-
type: '
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
source: {
|
|
2903
|
-
type: 'column_ref',
|
|
2904
|
-
table: null,
|
|
2905
|
-
column: 'transaction_date',
|
|
2946
|
+
type: 'function',
|
|
2947
|
+
name: {
|
|
2948
|
+
name: [
|
|
2949
|
+
{
|
|
2950
|
+
type: 'default',
|
|
2951
|
+
value: 'TO_CHAR',
|
|
2906
2952
|
},
|
|
2907
|
-
|
|
2953
|
+
],
|
|
2908
2954
|
},
|
|
2909
|
-
|
|
2910
|
-
type: '
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
source: {
|
|
2955
|
+
args: {
|
|
2956
|
+
type: 'expr_list',
|
|
2957
|
+
value: [
|
|
2958
|
+
{
|
|
2914
2959
|
type: 'function',
|
|
2915
2960
|
name: {
|
|
2916
2961
|
name: [
|
|
@@ -2926,16 +2971,146 @@ const queryPatterns = [
|
|
|
2926
2971
|
},
|
|
2927
2972
|
over: null,
|
|
2928
2973
|
},
|
|
2929
|
-
|
|
2974
|
+
{
|
|
2975
|
+
type: 'single_quote_string',
|
|
2976
|
+
value: 'YYYY-MM',
|
|
2977
|
+
},
|
|
2978
|
+
],
|
|
2930
2979
|
},
|
|
2931
2980
|
},
|
|
2932
2981
|
},
|
|
2933
|
-
with: null,
|
|
2934
2982
|
groupby: null,
|
|
2935
2983
|
having: null,
|
|
2936
2984
|
qualify: null,
|
|
2937
2985
|
orderby: null,
|
|
2938
|
-
limit:
|
|
2986
|
+
limit: {
|
|
2987
|
+
seperator: '',
|
|
2988
|
+
value: [],
|
|
2989
|
+
},
|
|
2990
|
+
window: null,
|
|
2991
|
+
},
|
|
2992
|
+
},
|
|
2993
|
+
],
|
|
2994
|
+
bigquery: [
|
|
2995
|
+
{
|
|
2996
|
+
query: `
|
|
2997
|
+
SELECT * FROM transactions
|
|
2998
|
+
WHERE EXTRACT(YEAR FROM transaction_date) = EXTRACT(YEAR FROM CURRENT_DATE())
|
|
2999
|
+
AND EXTRACT(MONTH FROM transaction_date) = EXTRACT(MONTH FROM CURRENT_DATE())
|
|
3000
|
+
`,
|
|
3001
|
+
value: function () {
|
|
3002
|
+
return 0;
|
|
3003
|
+
},
|
|
3004
|
+
unit: function (astWhere) {
|
|
3005
|
+
return extractTimeUnit(astWhere, (node) => node.left?.args?.field?.toLowerCase() ?? null);
|
|
3006
|
+
},
|
|
3007
|
+
ast: {
|
|
3008
|
+
type: 'select',
|
|
3009
|
+
as_struct_val: null,
|
|
3010
|
+
distinct: null,
|
|
3011
|
+
columns: [
|
|
3012
|
+
{
|
|
3013
|
+
expr: {
|
|
3014
|
+
type: 'column_ref',
|
|
3015
|
+
table: null,
|
|
3016
|
+
column: '*',
|
|
3017
|
+
},
|
|
3018
|
+
as: null,
|
|
3019
|
+
},
|
|
3020
|
+
],
|
|
3021
|
+
from: [
|
|
3022
|
+
{
|
|
3023
|
+
db: null,
|
|
3024
|
+
table: 'transactions',
|
|
3025
|
+
as: null,
|
|
3026
|
+
operator: null,
|
|
3027
|
+
},
|
|
3028
|
+
],
|
|
3029
|
+
for_sys_time_as_of: null,
|
|
3030
|
+
where: {
|
|
3031
|
+
type: 'binary_expr',
|
|
3032
|
+
operator: 'AND',
|
|
3033
|
+
left: {
|
|
3034
|
+
type: 'binary_expr',
|
|
3035
|
+
operator: '=',
|
|
3036
|
+
left: {
|
|
3037
|
+
type: 'extract',
|
|
3038
|
+
args: {
|
|
3039
|
+
field: 'YEAR',
|
|
3040
|
+
source: {
|
|
3041
|
+
type: 'column_ref',
|
|
3042
|
+
table: null,
|
|
3043
|
+
column: 'transaction_date',
|
|
3044
|
+
},
|
|
3045
|
+
},
|
|
3046
|
+
},
|
|
3047
|
+
right: {
|
|
3048
|
+
type: 'extract',
|
|
3049
|
+
args: {
|
|
3050
|
+
field: 'YEAR',
|
|
3051
|
+
source: {
|
|
3052
|
+
type: 'function',
|
|
3053
|
+
name: {
|
|
3054
|
+
name: [
|
|
3055
|
+
{
|
|
3056
|
+
type: 'default',
|
|
3057
|
+
value: 'CURRENT_DATE',
|
|
3058
|
+
},
|
|
3059
|
+
],
|
|
3060
|
+
},
|
|
3061
|
+
args: {
|
|
3062
|
+
type: 'expr_list',
|
|
3063
|
+
value: [],
|
|
3064
|
+
},
|
|
3065
|
+
over: null,
|
|
3066
|
+
},
|
|
3067
|
+
},
|
|
3068
|
+
},
|
|
3069
|
+
},
|
|
3070
|
+
right: {
|
|
3071
|
+
type: 'binary_expr',
|
|
3072
|
+
operator: '=',
|
|
3073
|
+
left: {
|
|
3074
|
+
type: 'extract',
|
|
3075
|
+
args: {
|
|
3076
|
+
field: 'MONTH',
|
|
3077
|
+
source: {
|
|
3078
|
+
type: 'column_ref',
|
|
3079
|
+
table: null,
|
|
3080
|
+
column: 'transaction_date',
|
|
3081
|
+
},
|
|
3082
|
+
},
|
|
3083
|
+
},
|
|
3084
|
+
right: {
|
|
3085
|
+
type: 'extract',
|
|
3086
|
+
args: {
|
|
3087
|
+
field: 'MONTH',
|
|
3088
|
+
source: {
|
|
3089
|
+
type: 'function',
|
|
3090
|
+
name: {
|
|
3091
|
+
name: [
|
|
3092
|
+
{
|
|
3093
|
+
type: 'default',
|
|
3094
|
+
value: 'CURRENT_DATE',
|
|
3095
|
+
},
|
|
3096
|
+
],
|
|
3097
|
+
},
|
|
3098
|
+
args: {
|
|
3099
|
+
type: 'expr_list',
|
|
3100
|
+
value: [],
|
|
3101
|
+
},
|
|
3102
|
+
over: null,
|
|
3103
|
+
},
|
|
3104
|
+
},
|
|
3105
|
+
},
|
|
3106
|
+
},
|
|
3107
|
+
},
|
|
3108
|
+
with: null,
|
|
3109
|
+
groupby: null,
|
|
3110
|
+
having: null,
|
|
3111
|
+
qualify: null,
|
|
3112
|
+
orderby: null,
|
|
3113
|
+
limit: null,
|
|
2939
3114
|
window: null,
|
|
2940
3115
|
_orderby: null,
|
|
2941
3116
|
_limit: null,
|
|
@@ -3023,6 +3198,118 @@ const queryPatterns = [
|
|
|
3023
3198
|
_limit: null,
|
|
3024
3199
|
},
|
|
3025
3200
|
},
|
|
3201
|
+
{
|
|
3202
|
+
query: `
|
|
3203
|
+
SELECT * FROM transactions
|
|
3204
|
+
WHERE DATETIME_TRUNC(transaction_ts, YEAR) = DATETIME_TRUNC(CURRENT_TIMESTAMP(), YEAR)
|
|
3205
|
+
`,
|
|
3206
|
+
value: function () {
|
|
3207
|
+
return 0;
|
|
3208
|
+
},
|
|
3209
|
+
unit: function (astWhere) {
|
|
3210
|
+
return (astWhere.left?.args?.value?.[1]?.column?.toLowerCase() ?? null);
|
|
3211
|
+
},
|
|
3212
|
+
ast: {
|
|
3213
|
+
type: 'select',
|
|
3214
|
+
as_struct_val: null,
|
|
3215
|
+
distinct: null,
|
|
3216
|
+
columns: [
|
|
3217
|
+
{
|
|
3218
|
+
expr: {
|
|
3219
|
+
type: 'column_ref',
|
|
3220
|
+
table: null,
|
|
3221
|
+
column: '*',
|
|
3222
|
+
},
|
|
3223
|
+
as: null,
|
|
3224
|
+
},
|
|
3225
|
+
],
|
|
3226
|
+
from: [
|
|
3227
|
+
{
|
|
3228
|
+
db: null,
|
|
3229
|
+
table: 'transactions',
|
|
3230
|
+
as: null,
|
|
3231
|
+
operator: null,
|
|
3232
|
+
},
|
|
3233
|
+
],
|
|
3234
|
+
for_sys_time_as_of: null,
|
|
3235
|
+
where: {
|
|
3236
|
+
type: 'binary_expr',
|
|
3237
|
+
operator: '=',
|
|
3238
|
+
left: {
|
|
3239
|
+
type: 'function',
|
|
3240
|
+
name: {
|
|
3241
|
+
name: [],
|
|
3242
|
+
schema: {
|
|
3243
|
+
type: 'default',
|
|
3244
|
+
value: 'DATETIME_TRUNC',
|
|
3245
|
+
},
|
|
3246
|
+
},
|
|
3247
|
+
args: {
|
|
3248
|
+
type: 'expr_list',
|
|
3249
|
+
value: [
|
|
3250
|
+
{
|
|
3251
|
+
type: 'column_ref',
|
|
3252
|
+
table: null,
|
|
3253
|
+
column: 'transaction_ts',
|
|
3254
|
+
},
|
|
3255
|
+
{
|
|
3256
|
+
type: 'column_ref',
|
|
3257
|
+
table: null,
|
|
3258
|
+
column: 'YEAR',
|
|
3259
|
+
},
|
|
3260
|
+
],
|
|
3261
|
+
},
|
|
3262
|
+
over: null,
|
|
3263
|
+
},
|
|
3264
|
+
right: {
|
|
3265
|
+
type: 'function',
|
|
3266
|
+
name: {
|
|
3267
|
+
name: [],
|
|
3268
|
+
schema: {
|
|
3269
|
+
type: 'default',
|
|
3270
|
+
value: 'DATETIME_TRUNC',
|
|
3271
|
+
},
|
|
3272
|
+
},
|
|
3273
|
+
args: {
|
|
3274
|
+
type: 'expr_list',
|
|
3275
|
+
value: [
|
|
3276
|
+
{
|
|
3277
|
+
type: 'function',
|
|
3278
|
+
name: {
|
|
3279
|
+
name: [
|
|
3280
|
+
{
|
|
3281
|
+
type: 'default',
|
|
3282
|
+
value: 'CURRENT_TIMESTAMP',
|
|
3283
|
+
},
|
|
3284
|
+
],
|
|
3285
|
+
},
|
|
3286
|
+
args: {
|
|
3287
|
+
type: 'expr_list',
|
|
3288
|
+
value: [],
|
|
3289
|
+
},
|
|
3290
|
+
over: null,
|
|
3291
|
+
},
|
|
3292
|
+
{
|
|
3293
|
+
type: 'column_ref',
|
|
3294
|
+
table: null,
|
|
3295
|
+
column: 'YEAR',
|
|
3296
|
+
},
|
|
3297
|
+
],
|
|
3298
|
+
},
|
|
3299
|
+
over: null,
|
|
3300
|
+
},
|
|
3301
|
+
},
|
|
3302
|
+
with: null,
|
|
3303
|
+
groupby: null,
|
|
3304
|
+
having: null,
|
|
3305
|
+
qualify: null,
|
|
3306
|
+
orderby: null,
|
|
3307
|
+
limit: null,
|
|
3308
|
+
window: null,
|
|
3309
|
+
_orderby: null,
|
|
3310
|
+
_limit: null,
|
|
3311
|
+
},
|
|
3312
|
+
},
|
|
3026
3313
|
],
|
|
3027
3314
|
mysql: [
|
|
3028
3315
|
{
|
|
@@ -3295,18 +3582,33 @@ const queryPatterns = [
|
|
|
3295
3582
|
window: null,
|
|
3296
3583
|
},
|
|
3297
3584
|
},
|
|
3298
|
-
],
|
|
3299
|
-
postgresql: [
|
|
3300
3585
|
{
|
|
3301
3586
|
query: `
|
|
3302
3587
|
SELECT * FROM transactions
|
|
3303
|
-
WHERE
|
|
3588
|
+
WHERE DATE_FORMAT(transaction_date, '%Y-%m') = DATE_FORMAT(CURRENT_DATE(), '%Y-%m')
|
|
3304
3589
|
`,
|
|
3305
3590
|
value: function () {
|
|
3306
3591
|
return 0;
|
|
3307
3592
|
},
|
|
3308
3593
|
unit: function (astWhere) {
|
|
3309
|
-
|
|
3594
|
+
const format = astWhere.left?.args?.value[1]?.value;
|
|
3595
|
+
if (!format) {
|
|
3596
|
+
return null;
|
|
3597
|
+
}
|
|
3598
|
+
switch (format) {
|
|
3599
|
+
case '%Y':
|
|
3600
|
+
return 'year';
|
|
3601
|
+
case '%Y-%m':
|
|
3602
|
+
return 'month';
|
|
3603
|
+
case '%Y-%u':
|
|
3604
|
+
return 'week';
|
|
3605
|
+
case '%Y-%m-%d':
|
|
3606
|
+
return 'day';
|
|
3607
|
+
case '%Y-%m-%d %H':
|
|
3608
|
+
return 'hour';
|
|
3609
|
+
default:
|
|
3610
|
+
return null;
|
|
3611
|
+
}
|
|
3310
3612
|
},
|
|
3311
3613
|
ast: {
|
|
3312
3614
|
with: null,
|
|
@@ -3344,17 +3646,13 @@ const queryPatterns = [
|
|
|
3344
3646
|
name: [
|
|
3345
3647
|
{
|
|
3346
3648
|
type: 'default',
|
|
3347
|
-
value: '
|
|
3649
|
+
value: 'DATE_FORMAT',
|
|
3348
3650
|
},
|
|
3349
3651
|
],
|
|
3350
3652
|
},
|
|
3351
3653
|
args: {
|
|
3352
3654
|
type: 'expr_list',
|
|
3353
3655
|
value: [
|
|
3354
|
-
{
|
|
3355
|
-
type: 'single_quote_string',
|
|
3356
|
-
value: 'month',
|
|
3357
|
-
},
|
|
3358
3656
|
{
|
|
3359
3657
|
type: 'column_ref',
|
|
3360
3658
|
table: null,
|
|
@@ -3365,6 +3663,10 @@ const queryPatterns = [
|
|
|
3365
3663
|
},
|
|
3366
3664
|
},
|
|
3367
3665
|
},
|
|
3666
|
+
{
|
|
3667
|
+
type: 'single_quote_string',
|
|
3668
|
+
value: '%Y-%m',
|
|
3669
|
+
},
|
|
3368
3670
|
],
|
|
3369
3671
|
},
|
|
3370
3672
|
},
|
|
@@ -3374,17 +3676,268 @@ const queryPatterns = [
|
|
|
3374
3676
|
name: [
|
|
3375
3677
|
{
|
|
3376
3678
|
type: 'default',
|
|
3377
|
-
value: '
|
|
3679
|
+
value: 'DATE_FORMAT',
|
|
3378
3680
|
},
|
|
3379
3681
|
],
|
|
3380
3682
|
},
|
|
3381
3683
|
args: {
|
|
3382
3684
|
type: 'expr_list',
|
|
3383
3685
|
value: [
|
|
3384
|
-
{
|
|
3385
|
-
type: '
|
|
3386
|
-
|
|
3387
|
-
|
|
3686
|
+
{
|
|
3687
|
+
type: 'function',
|
|
3688
|
+
name: {
|
|
3689
|
+
name: [
|
|
3690
|
+
{
|
|
3691
|
+
type: 'origin',
|
|
3692
|
+
value: 'CURRENT_DATE',
|
|
3693
|
+
},
|
|
3694
|
+
],
|
|
3695
|
+
},
|
|
3696
|
+
args: {
|
|
3697
|
+
type: 'expr_list',
|
|
3698
|
+
value: [],
|
|
3699
|
+
},
|
|
3700
|
+
over: null,
|
|
3701
|
+
},
|
|
3702
|
+
{
|
|
3703
|
+
type: 'single_quote_string',
|
|
3704
|
+
value: '%Y-%m',
|
|
3705
|
+
},
|
|
3706
|
+
],
|
|
3707
|
+
},
|
|
3708
|
+
},
|
|
3709
|
+
},
|
|
3710
|
+
groupby: null,
|
|
3711
|
+
having: null,
|
|
3712
|
+
orderby: null,
|
|
3713
|
+
limit: {
|
|
3714
|
+
seperator: '',
|
|
3715
|
+
value: [],
|
|
3716
|
+
},
|
|
3717
|
+
window: null,
|
|
3718
|
+
},
|
|
3719
|
+
},
|
|
3720
|
+
{
|
|
3721
|
+
query: `
|
|
3722
|
+
SELECT * FROM transactions
|
|
3723
|
+
WHERE DATE_TRUNC(transaction_date, MONTH) = DATE_TRUNC(CURRENT_DATE(), MONTH)
|
|
3724
|
+
`,
|
|
3725
|
+
value: function () {
|
|
3726
|
+
return 0;
|
|
3727
|
+
},
|
|
3728
|
+
unit: function (astWhere) {
|
|
3729
|
+
return (astWhere.left?.args?.value[1]?.column?.expr?.value?.toLowerCase() ??
|
|
3730
|
+
null);
|
|
3731
|
+
},
|
|
3732
|
+
ast: {
|
|
3733
|
+
with: null,
|
|
3734
|
+
type: 'select',
|
|
3735
|
+
options: null,
|
|
3736
|
+
distinct: {
|
|
3737
|
+
type: null,
|
|
3738
|
+
},
|
|
3739
|
+
columns: [
|
|
3740
|
+
{
|
|
3741
|
+
expr: {
|
|
3742
|
+
type: 'column_ref',
|
|
3743
|
+
table: null,
|
|
3744
|
+
column: '*',
|
|
3745
|
+
},
|
|
3746
|
+
as: null,
|
|
3747
|
+
},
|
|
3748
|
+
],
|
|
3749
|
+
into: {
|
|
3750
|
+
position: null,
|
|
3751
|
+
},
|
|
3752
|
+
from: [
|
|
3753
|
+
{
|
|
3754
|
+
db: null,
|
|
3755
|
+
table: 'transactions',
|
|
3756
|
+
as: null,
|
|
3757
|
+
},
|
|
3758
|
+
],
|
|
3759
|
+
where: {
|
|
3760
|
+
type: 'binary_expr',
|
|
3761
|
+
operator: '=',
|
|
3762
|
+
left: {
|
|
3763
|
+
type: 'function',
|
|
3764
|
+
name: {
|
|
3765
|
+
name: [
|
|
3766
|
+
{
|
|
3767
|
+
type: 'default',
|
|
3768
|
+
value: 'DATE_TRUNC',
|
|
3769
|
+
},
|
|
3770
|
+
],
|
|
3771
|
+
},
|
|
3772
|
+
args: {
|
|
3773
|
+
type: 'expr_list',
|
|
3774
|
+
value: [
|
|
3775
|
+
{
|
|
3776
|
+
type: 'column_ref',
|
|
3777
|
+
table: null,
|
|
3778
|
+
column: {
|
|
3779
|
+
expr: {
|
|
3780
|
+
type: 'default',
|
|
3781
|
+
value: 'transaction_date',
|
|
3782
|
+
},
|
|
3783
|
+
},
|
|
3784
|
+
},
|
|
3785
|
+
{
|
|
3786
|
+
type: 'column_ref',
|
|
3787
|
+
table: null,
|
|
3788
|
+
column: {
|
|
3789
|
+
expr: {
|
|
3790
|
+
type: 'default',
|
|
3791
|
+
value: 'MONTH',
|
|
3792
|
+
},
|
|
3793
|
+
},
|
|
3794
|
+
},
|
|
3795
|
+
],
|
|
3796
|
+
},
|
|
3797
|
+
},
|
|
3798
|
+
right: {
|
|
3799
|
+
type: 'function',
|
|
3800
|
+
name: {
|
|
3801
|
+
name: [
|
|
3802
|
+
{
|
|
3803
|
+
type: 'default',
|
|
3804
|
+
value: 'DATE_TRUNC',
|
|
3805
|
+
},
|
|
3806
|
+
],
|
|
3807
|
+
},
|
|
3808
|
+
args: {
|
|
3809
|
+
type: 'expr_list',
|
|
3810
|
+
value: [
|
|
3811
|
+
{
|
|
3812
|
+
type: 'function',
|
|
3813
|
+
name: {
|
|
3814
|
+
name: [
|
|
3815
|
+
{
|
|
3816
|
+
type: 'origin',
|
|
3817
|
+
value: 'CURRENT_DATE',
|
|
3818
|
+
},
|
|
3819
|
+
],
|
|
3820
|
+
},
|
|
3821
|
+
args: {
|
|
3822
|
+
type: 'expr_list',
|
|
3823
|
+
value: [],
|
|
3824
|
+
},
|
|
3825
|
+
over: null,
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
type: 'column_ref',
|
|
3829
|
+
table: null,
|
|
3830
|
+
column: {
|
|
3831
|
+
expr: {
|
|
3832
|
+
type: 'default',
|
|
3833
|
+
value: 'MONTH',
|
|
3834
|
+
},
|
|
3835
|
+
},
|
|
3836
|
+
},
|
|
3837
|
+
],
|
|
3838
|
+
},
|
|
3839
|
+
},
|
|
3840
|
+
},
|
|
3841
|
+
groupby: null,
|
|
3842
|
+
having: null,
|
|
3843
|
+
orderby: null,
|
|
3844
|
+
limit: {
|
|
3845
|
+
seperator: '',
|
|
3846
|
+
value: [],
|
|
3847
|
+
},
|
|
3848
|
+
window: null,
|
|
3849
|
+
},
|
|
3850
|
+
},
|
|
3851
|
+
],
|
|
3852
|
+
postgresql: [
|
|
3853
|
+
{
|
|
3854
|
+
query: `
|
|
3855
|
+
SELECT * FROM transactions
|
|
3856
|
+
WHERE DATE_TRUNC('month', transaction_date) = DATE_TRUNC('month', CURRENT_DATE)
|
|
3857
|
+
`,
|
|
3858
|
+
value: function () {
|
|
3859
|
+
return 0;
|
|
3860
|
+
},
|
|
3861
|
+
unit: function (astWhere) {
|
|
3862
|
+
return astWhere.left?.args?.value[0]?.value ?? null;
|
|
3863
|
+
},
|
|
3864
|
+
ast: {
|
|
3865
|
+
with: null,
|
|
3866
|
+
type: 'select',
|
|
3867
|
+
options: null,
|
|
3868
|
+
distinct: {
|
|
3869
|
+
type: null,
|
|
3870
|
+
},
|
|
3871
|
+
columns: [
|
|
3872
|
+
{
|
|
3873
|
+
expr: {
|
|
3874
|
+
type: 'column_ref',
|
|
3875
|
+
table: null,
|
|
3876
|
+
column: '*',
|
|
3877
|
+
},
|
|
3878
|
+
as: null,
|
|
3879
|
+
},
|
|
3880
|
+
],
|
|
3881
|
+
into: {
|
|
3882
|
+
position: null,
|
|
3883
|
+
},
|
|
3884
|
+
from: [
|
|
3885
|
+
{
|
|
3886
|
+
db: null,
|
|
3887
|
+
table: 'transactions',
|
|
3888
|
+
as: null,
|
|
3889
|
+
},
|
|
3890
|
+
],
|
|
3891
|
+
where: {
|
|
3892
|
+
type: 'binary_expr',
|
|
3893
|
+
operator: '=',
|
|
3894
|
+
left: {
|
|
3895
|
+
type: 'function',
|
|
3896
|
+
name: {
|
|
3897
|
+
name: [
|
|
3898
|
+
{
|
|
3899
|
+
type: 'default',
|
|
3900
|
+
value: 'DATE_TRUNC',
|
|
3901
|
+
},
|
|
3902
|
+
],
|
|
3903
|
+
},
|
|
3904
|
+
args: {
|
|
3905
|
+
type: 'expr_list',
|
|
3906
|
+
value: [
|
|
3907
|
+
{
|
|
3908
|
+
type: 'single_quote_string',
|
|
3909
|
+
value: 'month',
|
|
3910
|
+
},
|
|
3911
|
+
{
|
|
3912
|
+
type: 'column_ref',
|
|
3913
|
+
table: null,
|
|
3914
|
+
column: {
|
|
3915
|
+
expr: {
|
|
3916
|
+
type: 'default',
|
|
3917
|
+
value: 'transaction_date',
|
|
3918
|
+
},
|
|
3919
|
+
},
|
|
3920
|
+
},
|
|
3921
|
+
],
|
|
3922
|
+
},
|
|
3923
|
+
},
|
|
3924
|
+
right: {
|
|
3925
|
+
type: 'function',
|
|
3926
|
+
name: {
|
|
3927
|
+
name: [
|
|
3928
|
+
{
|
|
3929
|
+
type: 'default',
|
|
3930
|
+
value: 'DATE_TRUNC',
|
|
3931
|
+
},
|
|
3932
|
+
],
|
|
3933
|
+
},
|
|
3934
|
+
args: {
|
|
3935
|
+
type: 'expr_list',
|
|
3936
|
+
value: [
|
|
3937
|
+
{
|
|
3938
|
+
type: 'single_quote_string',
|
|
3939
|
+
value: 'month',
|
|
3940
|
+
},
|
|
3388
3941
|
{
|
|
3389
3942
|
type: 'function',
|
|
3390
3943
|
name: {
|
|
@@ -5082,8 +5635,8 @@ function generateWhereChecker(astWhere) {
|
|
|
5082
5635
|
case 'function':
|
|
5083
5636
|
if (node?.name && typeof node.name === 'string') {
|
|
5084
5637
|
resultString = resultString.concat(` && (${testWhereNode}?.name?.toLowerCase() === '${node.name.toLowerCase()} ` +
|
|
5085
|
-
`|| (['CURRENT_DATE', 'CURRENT_TIMESTAMP'].includes(${testWhereNode}?.name
|
|
5086
|
-
`&& ['CURRENT_DATE', 'CURRENT_TIMESTAMP'].includes('${node.name
|
|
5638
|
+
`|| (['CURRENT_DATE', 'CURRENT_TIMESTAMP'].includes(${testWhereNode}?.name)) ` +
|
|
5639
|
+
`&& ['CURRENT_DATE', 'CURRENT_TIMESTAMP'].includes('${node.name}')) ` +
|
|
5087
5640
|
`|| (['year', 'month', 'quarter', 'day', 'week', 'hour'].includes(${testWhereNode}?.name?.toLowerCase()) ` +
|
|
5088
5641
|
`&& ['year', 'month', 'quarter', 'day', 'week', 'hour'].includes('${node.name.toLowerCase()}')))`);
|
|
5089
5642
|
}
|
|
@@ -5303,12 +5856,17 @@ function lowerFunctionToField(lower, db) {
|
|
|
5303
5856
|
function getFieldFromExpression(expr) {
|
|
5304
5857
|
return (expr.column?.expr?.value ||
|
|
5305
5858
|
expr.column ||
|
|
5306
|
-
expr.args?.value?.[1]?.value ||
|
|
5307
|
-
expr.args?.value?.[1]?.column?.expr?.value ||
|
|
5308
5859
|
expr.args?.value?.[1]?.expr?.column ||
|
|
5309
5860
|
expr.args?.value?.[1]?.args?.value?.[0]?.column?.expr?.value ||
|
|
5310
5861
|
expr.args?.value?.[0]?.value?.expr?.value ||
|
|
5862
|
+
expr.args?.value?.[1]?.column?.expr?.value ||
|
|
5311
5863
|
expr.args?.value?.[0]?.column?.expr?.value ||
|
|
5864
|
+
(expr.name?.schema?.value !== 'DATETIME_TRUNC' // BigQuery edge case
|
|
5865
|
+
? expr.args?.value?.[1]?.column
|
|
5866
|
+
: null) ||
|
|
5867
|
+
(expr.args?.value?.[1]?.type === 'double_quote_string'
|
|
5868
|
+
? expr.args?.value?.[1]?.value
|
|
5869
|
+
: null) ||
|
|
5312
5870
|
expr.args?.value?.[0]?.column ||
|
|
5313
5871
|
expr.args?.value?.[0]?.value ||
|
|
5314
5872
|
expr.args?.source?.column?.expr?.value ||
|
|
@@ -5733,7 +6291,11 @@ const filterTreeToAst = (filterTree, db) => {
|
|
|
5733
6291
|
}
|
|
5734
6292
|
}
|
|
5735
6293
|
else {
|
|
5736
|
-
astNode = {
|
|
6294
|
+
astNode = {
|
|
6295
|
+
...astNode,
|
|
6296
|
+
type: 'binary_expr',
|
|
6297
|
+
operator: node.operator?.toUpperCase(),
|
|
6298
|
+
};
|
|
5737
6299
|
if (node.leftNode) {
|
|
5738
6300
|
astNode.left = buildTree(node.leftNode, {});
|
|
5739
6301
|
}
|
|
@@ -6204,6 +6766,7 @@ const filterToAst = (filter, db) => {
|
|
|
6204
6766
|
parentheses: true,
|
|
6205
6767
|
},
|
|
6206
6768
|
},
|
|
6769
|
+
parentheses: true,
|
|
6207
6770
|
};
|
|
6208
6771
|
case 'snowflake':
|
|
6209
6772
|
return {
|
|
@@ -6229,12 +6792,7 @@ const filterToAst = (filter, db) => {
|
|
|
6229
6792
|
{
|
|
6230
6793
|
type: 'column_ref',
|
|
6231
6794
|
table: null,
|
|
6232
|
-
column:
|
|
6233
|
-
expr: {
|
|
6234
|
-
type: 'default',
|
|
6235
|
-
value: field,
|
|
6236
|
-
},
|
|
6237
|
-
},
|
|
6795
|
+
column: field,
|
|
6238
6796
|
},
|
|
6239
6797
|
],
|
|
6240
6798
|
},
|
|
@@ -6277,184 +6835,115 @@ const filterToAst = (filter, db) => {
|
|
|
6277
6835
|
},
|
|
6278
6836
|
};
|
|
6279
6837
|
case 'bigquery':
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
type: 'column_ref',
|
|
6291
|
-
table: null,
|
|
6292
|
-
column: field,
|
|
6293
|
-
},
|
|
6294
|
-
},
|
|
6838
|
+
return {
|
|
6839
|
+
type: 'binary_expr',
|
|
6840
|
+
operator: '=',
|
|
6841
|
+
left: {
|
|
6842
|
+
type: 'function',
|
|
6843
|
+
name: {
|
|
6844
|
+
name: [],
|
|
6845
|
+
schema: {
|
|
6846
|
+
type: 'default',
|
|
6847
|
+
value: 'DATETIME_TRUNC',
|
|
6295
6848
|
},
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
{
|
|
6305
|
-
type: 'default',
|
|
6306
|
-
value: 'CURRENT_DATE',
|
|
6307
|
-
},
|
|
6308
|
-
],
|
|
6309
|
-
},
|
|
6310
|
-
args: {
|
|
6311
|
-
type: 'expr_list',
|
|
6312
|
-
value: [],
|
|
6313
|
-
},
|
|
6314
|
-
over: null,
|
|
6315
|
-
},
|
|
6849
|
+
},
|
|
6850
|
+
args: {
|
|
6851
|
+
type: 'expr_list',
|
|
6852
|
+
value: [
|
|
6853
|
+
{
|
|
6854
|
+
type: 'column_ref',
|
|
6855
|
+
table: null,
|
|
6856
|
+
column: field,
|
|
6316
6857
|
},
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
type: 'binary_expr',
|
|
6322
|
-
operator: 'AND',
|
|
6323
|
-
left: {
|
|
6324
|
-
type: 'binary_expr',
|
|
6325
|
-
operator: '=',
|
|
6326
|
-
left: {
|
|
6327
|
-
type: 'extract',
|
|
6328
|
-
args: {
|
|
6329
|
-
field: 'YEAR',
|
|
6330
|
-
source: {
|
|
6331
|
-
type: 'column_ref',
|
|
6332
|
-
table: null,
|
|
6333
|
-
column: field,
|
|
6334
|
-
},
|
|
6335
|
-
},
|
|
6858
|
+
{
|
|
6859
|
+
type: 'column_ref',
|
|
6860
|
+
table: null,
|
|
6861
|
+
column: filter.value.unit,
|
|
6336
6862
|
},
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6863
|
+
],
|
|
6864
|
+
},
|
|
6865
|
+
},
|
|
6866
|
+
right: {
|
|
6867
|
+
type: 'function',
|
|
6868
|
+
name: {
|
|
6869
|
+
name: [],
|
|
6870
|
+
schema: {
|
|
6871
|
+
type: 'default',
|
|
6872
|
+
value: 'DATETIME_TRUNC',
|
|
6873
|
+
},
|
|
6874
|
+
},
|
|
6875
|
+
args: {
|
|
6876
|
+
type: 'expr_list',
|
|
6877
|
+
value: [
|
|
6878
|
+
{
|
|
6879
|
+
type: 'function',
|
|
6880
|
+
name: {
|
|
6881
|
+
name: [
|
|
6882
|
+
{
|
|
6883
|
+
type: 'origin',
|
|
6884
|
+
value: 'CURRENT_TIMESTAMP',
|
|
6354
6885
|
},
|
|
6355
|
-
|
|
6356
|
-
},
|
|
6886
|
+
],
|
|
6357
6887
|
},
|
|
6358
|
-
},
|
|
6359
|
-
},
|
|
6360
|
-
right: {
|
|
6361
|
-
type: 'binary_expr',
|
|
6362
|
-
operator: '=',
|
|
6363
|
-
left: {
|
|
6364
|
-
type: 'extract',
|
|
6365
6888
|
args: {
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
type: 'column_ref',
|
|
6369
|
-
table: null,
|
|
6370
|
-
column: field,
|
|
6371
|
-
},
|
|
6889
|
+
type: 'expr_list',
|
|
6890
|
+
value: [],
|
|
6372
6891
|
},
|
|
6892
|
+
over: null,
|
|
6373
6893
|
},
|
|
6374
|
-
|
|
6375
|
-
type: '
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
source: {
|
|
6379
|
-
type: 'function',
|
|
6380
|
-
name: {
|
|
6381
|
-
name: [
|
|
6382
|
-
{
|
|
6383
|
-
type: 'default',
|
|
6384
|
-
value: 'CURRENT_DATE',
|
|
6385
|
-
},
|
|
6386
|
-
],
|
|
6387
|
-
},
|
|
6388
|
-
args: {
|
|
6389
|
-
type: 'expr_list',
|
|
6390
|
-
value: [],
|
|
6391
|
-
},
|
|
6392
|
-
over: null,
|
|
6393
|
-
},
|
|
6394
|
-
},
|
|
6894
|
+
{
|
|
6895
|
+
type: 'column_ref',
|
|
6896
|
+
table: null,
|
|
6897
|
+
column: filter.value.unit,
|
|
6395
6898
|
},
|
|
6396
|
-
|
|
6397
|
-
}
|
|
6398
|
-
|
|
6399
|
-
|
|
6899
|
+
],
|
|
6900
|
+
},
|
|
6901
|
+
},
|
|
6902
|
+
};
|
|
6903
|
+
case 'mysql': {
|
|
6904
|
+
if (filter.value.unit === 'quarter') {
|
|
6905
|
+
return {
|
|
6906
|
+
type: 'binary_expr',
|
|
6907
|
+
operator: 'AND',
|
|
6908
|
+
left: {
|
|
6400
6909
|
type: 'binary_expr',
|
|
6401
|
-
operator: '
|
|
6910
|
+
operator: '=',
|
|
6402
6911
|
left: {
|
|
6403
|
-
type: '
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6912
|
+
type: 'function',
|
|
6913
|
+
name: {
|
|
6914
|
+
name: [
|
|
6915
|
+
{
|
|
6916
|
+
type: 'default',
|
|
6917
|
+
value: 'YEAR',
|
|
6918
|
+
},
|
|
6919
|
+
],
|
|
6920
|
+
},
|
|
6921
|
+
args: {
|
|
6922
|
+
type: 'expr_list',
|
|
6923
|
+
value: [
|
|
6924
|
+
{
|
|
6410
6925
|
type: 'column_ref',
|
|
6411
6926
|
table: null,
|
|
6412
6927
|
column: field,
|
|
6413
6928
|
},
|
|
6414
|
-
|
|
6415
|
-
},
|
|
6416
|
-
right: {
|
|
6417
|
-
type: 'extract',
|
|
6418
|
-
args: {
|
|
6419
|
-
field: 'YEAR',
|
|
6420
|
-
source: {
|
|
6421
|
-
type: 'function',
|
|
6422
|
-
name: {
|
|
6423
|
-
name: [
|
|
6424
|
-
{
|
|
6425
|
-
type: 'default',
|
|
6426
|
-
value: 'CURRENT_DATE',
|
|
6427
|
-
},
|
|
6428
|
-
],
|
|
6429
|
-
},
|
|
6430
|
-
args: {
|
|
6431
|
-
type: 'expr_list',
|
|
6432
|
-
value: [],
|
|
6433
|
-
},
|
|
6434
|
-
over: null,
|
|
6435
|
-
},
|
|
6436
|
-
},
|
|
6929
|
+
],
|
|
6437
6930
|
},
|
|
6931
|
+
over: null,
|
|
6438
6932
|
},
|
|
6439
6933
|
right: {
|
|
6440
|
-
type: '
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
source: {
|
|
6447
|
-
type: 'column_ref',
|
|
6448
|
-
table: null,
|
|
6449
|
-
column: field,
|
|
6934
|
+
type: 'function',
|
|
6935
|
+
name: {
|
|
6936
|
+
name: [
|
|
6937
|
+
{
|
|
6938
|
+
type: 'default',
|
|
6939
|
+
value: 'YEAR',
|
|
6450
6940
|
},
|
|
6451
|
-
|
|
6941
|
+
],
|
|
6452
6942
|
},
|
|
6453
|
-
|
|
6454
|
-
type: '
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
source: {
|
|
6943
|
+
args: {
|
|
6944
|
+
type: 'expr_list',
|
|
6945
|
+
value: [
|
|
6946
|
+
{
|
|
6458
6947
|
type: 'function',
|
|
6459
6948
|
name: {
|
|
6460
6949
|
name: [
|
|
@@ -6470,111 +6959,50 @@ const filterToAst = (filter, db) => {
|
|
|
6470
6959
|
},
|
|
6471
6960
|
over: null,
|
|
6472
6961
|
},
|
|
6473
|
-
|
|
6962
|
+
],
|
|
6474
6963
|
},
|
|
6964
|
+
over: null,
|
|
6475
6965
|
},
|
|
6476
|
-
}
|
|
6477
|
-
|
|
6478
|
-
return {
|
|
6966
|
+
},
|
|
6967
|
+
right: {
|
|
6479
6968
|
type: 'binary_expr',
|
|
6480
|
-
operator: '
|
|
6969
|
+
operator: '=',
|
|
6481
6970
|
left: {
|
|
6482
|
-
type: '
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
type: 'extract',
|
|
6489
|
-
args: {
|
|
6490
|
-
field: 'YEAR',
|
|
6491
|
-
source: {
|
|
6492
|
-
type: 'column_ref',
|
|
6493
|
-
table: null,
|
|
6494
|
-
column: field,
|
|
6495
|
-
},
|
|
6496
|
-
},
|
|
6497
|
-
},
|
|
6498
|
-
right: {
|
|
6499
|
-
type: 'extract',
|
|
6500
|
-
args: {
|
|
6501
|
-
field: 'YEAR',
|
|
6502
|
-
source: {
|
|
6503
|
-
type: 'function',
|
|
6504
|
-
name: {
|
|
6505
|
-
name: [
|
|
6506
|
-
{
|
|
6507
|
-
type: 'default',
|
|
6508
|
-
value: 'CURRENT_DATE',
|
|
6509
|
-
},
|
|
6510
|
-
],
|
|
6511
|
-
},
|
|
6512
|
-
args: {
|
|
6513
|
-
type: 'expr_list',
|
|
6514
|
-
value: [],
|
|
6515
|
-
},
|
|
6516
|
-
over: null,
|
|
6517
|
-
},
|
|
6971
|
+
type: 'function',
|
|
6972
|
+
name: {
|
|
6973
|
+
name: [
|
|
6974
|
+
{
|
|
6975
|
+
type: 'default',
|
|
6976
|
+
value: 'QUARTER',
|
|
6518
6977
|
},
|
|
6519
|
-
|
|
6978
|
+
],
|
|
6520
6979
|
},
|
|
6521
|
-
|
|
6522
|
-
type: '
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
source: {
|
|
6529
|
-
type: 'column_ref',
|
|
6530
|
-
table: null,
|
|
6531
|
-
column: field,
|
|
6532
|
-
},
|
|
6533
|
-
},
|
|
6534
|
-
},
|
|
6535
|
-
right: {
|
|
6536
|
-
type: 'extract',
|
|
6537
|
-
args: {
|
|
6538
|
-
field: 'MONTH',
|
|
6539
|
-
source: {
|
|
6540
|
-
type: 'function',
|
|
6541
|
-
name: {
|
|
6542
|
-
name: [
|
|
6543
|
-
{
|
|
6544
|
-
type: 'default',
|
|
6545
|
-
value: 'CURRENT_DATE',
|
|
6546
|
-
},
|
|
6547
|
-
],
|
|
6548
|
-
},
|
|
6549
|
-
args: {
|
|
6550
|
-
type: 'expr_list',
|
|
6551
|
-
value: [],
|
|
6552
|
-
},
|
|
6553
|
-
over: null,
|
|
6554
|
-
},
|
|
6980
|
+
args: {
|
|
6981
|
+
type: 'expr_list',
|
|
6982
|
+
value: [
|
|
6983
|
+
{
|
|
6984
|
+
type: 'column_ref',
|
|
6985
|
+
table: null,
|
|
6986
|
+
column: field,
|
|
6555
6987
|
},
|
|
6556
|
-
|
|
6988
|
+
],
|
|
6557
6989
|
},
|
|
6990
|
+
over: null,
|
|
6558
6991
|
},
|
|
6559
6992
|
right: {
|
|
6560
|
-
type: '
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
source: {
|
|
6567
|
-
type: 'column_ref',
|
|
6568
|
-
table: null,
|
|
6569
|
-
column: field,
|
|
6993
|
+
type: 'function',
|
|
6994
|
+
name: {
|
|
6995
|
+
name: [
|
|
6996
|
+
{
|
|
6997
|
+
type: 'default',
|
|
6998
|
+
value: 'QUARTER',
|
|
6570
6999
|
},
|
|
6571
|
-
|
|
7000
|
+
],
|
|
6572
7001
|
},
|
|
6573
|
-
|
|
6574
|
-
type: '
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
source: {
|
|
7002
|
+
args: {
|
|
7003
|
+
type: 'expr_list',
|
|
7004
|
+
value: [
|
|
7005
|
+
{
|
|
6578
7006
|
type: 'function',
|
|
6579
7007
|
name: {
|
|
6580
7008
|
name: [
|
|
@@ -6590,1228 +7018,112 @@ const filterToAst = (filter, db) => {
|
|
|
6590
7018
|
},
|
|
6591
7019
|
over: null,
|
|
6592
7020
|
},
|
|
6593
|
-
|
|
7021
|
+
],
|
|
6594
7022
|
},
|
|
7023
|
+
over: null,
|
|
6595
7024
|
},
|
|
6596
|
-
}
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
},
|
|
6638
|
-
},
|
|
6639
|
-
},
|
|
6640
|
-
},
|
|
6641
|
-
right: {
|
|
6642
|
-
type: 'binary_expr',
|
|
6643
|
-
operator: '=',
|
|
6644
|
-
left: {
|
|
6645
|
-
type: 'extract',
|
|
6646
|
-
args: {
|
|
6647
|
-
field: 'MONTH',
|
|
6648
|
-
source: {
|
|
6649
|
-
type: 'column_ref',
|
|
6650
|
-
table: null,
|
|
6651
|
-
column: field,
|
|
6652
|
-
},
|
|
6653
|
-
},
|
|
6654
|
-
},
|
|
6655
|
-
right: {
|
|
6656
|
-
type: 'extract',
|
|
6657
|
-
args: {
|
|
6658
|
-
field: 'MONTH',
|
|
6659
|
-
source: {
|
|
6660
|
-
type: 'function',
|
|
6661
|
-
name: {
|
|
6662
|
-
name: [
|
|
6663
|
-
{
|
|
6664
|
-
type: 'default',
|
|
6665
|
-
value: 'CURRENT_DATE',
|
|
6666
|
-
},
|
|
6667
|
-
],
|
|
6668
|
-
},
|
|
6669
|
-
args: {
|
|
6670
|
-
type: 'expr_list',
|
|
6671
|
-
value: [],
|
|
6672
|
-
},
|
|
6673
|
-
over: null,
|
|
6674
|
-
},
|
|
6675
|
-
},
|
|
6676
|
-
},
|
|
6677
|
-
},
|
|
6678
|
-
},
|
|
6679
|
-
right: {
|
|
6680
|
-
type: 'binary_expr',
|
|
6681
|
-
operator: '=',
|
|
6682
|
-
left: {
|
|
6683
|
-
type: 'extract',
|
|
6684
|
-
args: {
|
|
6685
|
-
field: 'DAY',
|
|
6686
|
-
source: {
|
|
6687
|
-
type: 'column_ref',
|
|
6688
|
-
table: null,
|
|
6689
|
-
column: field,
|
|
6690
|
-
},
|
|
6691
|
-
},
|
|
6692
|
-
},
|
|
6693
|
-
right: {
|
|
6694
|
-
type: 'extract',
|
|
6695
|
-
args: {
|
|
6696
|
-
field: 'DAY',
|
|
6697
|
-
source: {
|
|
6698
|
-
type: 'function',
|
|
6699
|
-
name: {
|
|
6700
|
-
name: [
|
|
6701
|
-
{
|
|
6702
|
-
type: 'default',
|
|
6703
|
-
value: 'CURRENT_DATE',
|
|
6704
|
-
},
|
|
6705
|
-
],
|
|
6706
|
-
},
|
|
6707
|
-
args: {
|
|
6708
|
-
type: 'expr_list',
|
|
6709
|
-
value: [],
|
|
6710
|
-
},
|
|
6711
|
-
over: null,
|
|
6712
|
-
},
|
|
6713
|
-
},
|
|
6714
|
-
},
|
|
6715
|
-
},
|
|
6716
|
-
};
|
|
6717
|
-
case 'hour':
|
|
6718
|
-
return {
|
|
6719
|
-
type: 'binary_expr',
|
|
6720
|
-
operator: 'AND',
|
|
6721
|
-
left: {
|
|
6722
|
-
type: 'binary_expr',
|
|
6723
|
-
operator: 'AND',
|
|
6724
|
-
left: {
|
|
6725
|
-
type: 'binary_expr',
|
|
6726
|
-
operator: 'AND',
|
|
6727
|
-
left: {
|
|
6728
|
-
type: 'binary_expr',
|
|
6729
|
-
operator: '=',
|
|
6730
|
-
left: {
|
|
6731
|
-
type: 'extract',
|
|
6732
|
-
args: {
|
|
6733
|
-
field: 'YEAR',
|
|
6734
|
-
source: {
|
|
6735
|
-
type: 'column_ref',
|
|
6736
|
-
table: null,
|
|
6737
|
-
column: field,
|
|
6738
|
-
},
|
|
6739
|
-
},
|
|
6740
|
-
},
|
|
6741
|
-
right: {
|
|
6742
|
-
type: 'extract',
|
|
6743
|
-
args: {
|
|
6744
|
-
field: 'YEAR',
|
|
6745
|
-
source: {
|
|
6746
|
-
type: 'function',
|
|
6747
|
-
name: {
|
|
6748
|
-
name: [
|
|
6749
|
-
{
|
|
6750
|
-
type: 'default',
|
|
6751
|
-
value: 'CURRENT_TIMESTAMP',
|
|
6752
|
-
},
|
|
6753
|
-
],
|
|
6754
|
-
},
|
|
6755
|
-
args: {
|
|
6756
|
-
type: 'expr_list',
|
|
6757
|
-
value: [],
|
|
6758
|
-
},
|
|
6759
|
-
over: null,
|
|
6760
|
-
},
|
|
6761
|
-
},
|
|
6762
|
-
},
|
|
6763
|
-
},
|
|
6764
|
-
right: {
|
|
6765
|
-
type: 'binary_expr',
|
|
6766
|
-
operator: '=',
|
|
6767
|
-
left: {
|
|
6768
|
-
type: 'extract',
|
|
6769
|
-
args: {
|
|
6770
|
-
field: 'MONTH',
|
|
6771
|
-
source: {
|
|
6772
|
-
type: 'column_ref',
|
|
6773
|
-
table: null,
|
|
6774
|
-
column: field,
|
|
6775
|
-
},
|
|
6776
|
-
},
|
|
6777
|
-
},
|
|
6778
|
-
right: {
|
|
6779
|
-
type: 'extract',
|
|
6780
|
-
args: {
|
|
6781
|
-
field: 'MONTH',
|
|
6782
|
-
source: {
|
|
6783
|
-
type: 'function',
|
|
6784
|
-
name: {
|
|
6785
|
-
name: [
|
|
6786
|
-
{
|
|
6787
|
-
type: 'default',
|
|
6788
|
-
value: 'CURRENT_TIMESTAMP',
|
|
6789
|
-
},
|
|
6790
|
-
],
|
|
6791
|
-
},
|
|
6792
|
-
args: {
|
|
6793
|
-
type: 'expr_list',
|
|
6794
|
-
value: [],
|
|
6795
|
-
},
|
|
6796
|
-
over: null,
|
|
6797
|
-
},
|
|
6798
|
-
},
|
|
6799
|
-
},
|
|
6800
|
-
},
|
|
6801
|
-
},
|
|
6802
|
-
right: {
|
|
6803
|
-
type: 'binary_expr',
|
|
6804
|
-
operator: '=',
|
|
6805
|
-
left: {
|
|
6806
|
-
type: 'extract',
|
|
6807
|
-
args: {
|
|
6808
|
-
field: 'DAY',
|
|
6809
|
-
source: {
|
|
6810
|
-
type: 'column_ref',
|
|
6811
|
-
table: null,
|
|
6812
|
-
column: field,
|
|
6813
|
-
},
|
|
6814
|
-
},
|
|
6815
|
-
},
|
|
6816
|
-
right: {
|
|
6817
|
-
type: 'extract',
|
|
6818
|
-
args: {
|
|
6819
|
-
field: 'DAY',
|
|
6820
|
-
source: {
|
|
6821
|
-
type: 'function',
|
|
6822
|
-
name: {
|
|
6823
|
-
name: [
|
|
6824
|
-
{
|
|
6825
|
-
type: 'default',
|
|
6826
|
-
value: 'CURRENT_TIMESTAMP',
|
|
6827
|
-
},
|
|
6828
|
-
],
|
|
6829
|
-
},
|
|
6830
|
-
args: {
|
|
6831
|
-
type: 'expr_list',
|
|
6832
|
-
value: [],
|
|
6833
|
-
},
|
|
6834
|
-
over: null,
|
|
6835
|
-
},
|
|
6836
|
-
},
|
|
6837
|
-
},
|
|
6838
|
-
},
|
|
6839
|
-
},
|
|
6840
|
-
right: {
|
|
6841
|
-
type: 'binary_expr',
|
|
6842
|
-
operator: '=',
|
|
6843
|
-
left: {
|
|
6844
|
-
type: 'extract',
|
|
6845
|
-
args: {
|
|
6846
|
-
field: 'HOUR',
|
|
6847
|
-
source: {
|
|
6848
|
-
type: 'column_ref',
|
|
6849
|
-
table: null,
|
|
6850
|
-
column: field,
|
|
6851
|
-
},
|
|
6852
|
-
},
|
|
6853
|
-
},
|
|
6854
|
-
right: {
|
|
6855
|
-
type: 'extract',
|
|
6856
|
-
args: {
|
|
6857
|
-
field: 'HOUR',
|
|
6858
|
-
source: {
|
|
6859
|
-
type: 'function',
|
|
6860
|
-
name: {
|
|
6861
|
-
name: [
|
|
6862
|
-
{
|
|
6863
|
-
type: 'default',
|
|
6864
|
-
value: 'CURRENT_TIMESTAMP',
|
|
6865
|
-
},
|
|
6866
|
-
],
|
|
6867
|
-
},
|
|
6868
|
-
args: {
|
|
6869
|
-
type: 'expr_list',
|
|
6870
|
-
value: [],
|
|
6871
|
-
},
|
|
6872
|
-
over: null,
|
|
6873
|
-
},
|
|
6874
|
-
},
|
|
6875
|
-
},
|
|
6876
|
-
},
|
|
6877
|
-
};
|
|
6878
|
-
default:
|
|
6879
|
-
console.error('Unknown filter time unit: ', filter.value.unit);
|
|
6880
|
-
return null;
|
|
6881
|
-
}
|
|
6882
|
-
case 'mysql':
|
|
6883
|
-
switch (filter.value.unit) {
|
|
6884
|
-
case 'year':
|
|
6885
|
-
return {
|
|
6886
|
-
type: 'binary_expr',
|
|
6887
|
-
operator: '=',
|
|
6888
|
-
left: {
|
|
6889
|
-
type: 'function',
|
|
6890
|
-
name: {
|
|
6891
|
-
name: [
|
|
6892
|
-
{
|
|
6893
|
-
type: 'default',
|
|
6894
|
-
value: 'YEAR',
|
|
6895
|
-
},
|
|
6896
|
-
],
|
|
6897
|
-
},
|
|
6898
|
-
args: {
|
|
6899
|
-
type: 'expr_list',
|
|
6900
|
-
value: [
|
|
6901
|
-
{
|
|
6902
|
-
type: 'column_ref',
|
|
6903
|
-
table: null,
|
|
6904
|
-
column: field,
|
|
6905
|
-
},
|
|
6906
|
-
],
|
|
6907
|
-
},
|
|
6908
|
-
over: null,
|
|
6909
|
-
},
|
|
6910
|
-
right: {
|
|
6911
|
-
type: 'function',
|
|
6912
|
-
name: {
|
|
6913
|
-
name: [
|
|
6914
|
-
{
|
|
6915
|
-
type: 'default',
|
|
6916
|
-
value: 'YEAR',
|
|
6917
|
-
},
|
|
6918
|
-
],
|
|
6919
|
-
},
|
|
6920
|
-
args: {
|
|
6921
|
-
type: 'expr_list',
|
|
6922
|
-
value: [
|
|
6923
|
-
{
|
|
6924
|
-
type: 'function',
|
|
6925
|
-
name: {
|
|
6926
|
-
name: [
|
|
6927
|
-
{
|
|
6928
|
-
type: 'default',
|
|
6929
|
-
value: 'CURRENT_DATE',
|
|
6930
|
-
},
|
|
6931
|
-
],
|
|
6932
|
-
},
|
|
6933
|
-
args: {
|
|
6934
|
-
type: 'expr_list',
|
|
6935
|
-
value: [],
|
|
6936
|
-
},
|
|
6937
|
-
over: null,
|
|
6938
|
-
},
|
|
6939
|
-
],
|
|
6940
|
-
},
|
|
6941
|
-
over: null,
|
|
6942
|
-
},
|
|
6943
|
-
};
|
|
6944
|
-
case 'quarter':
|
|
6945
|
-
return {
|
|
6946
|
-
type: 'binary_expr',
|
|
6947
|
-
operator: 'AND',
|
|
6948
|
-
left: {
|
|
6949
|
-
type: 'binary_expr',
|
|
6950
|
-
operator: '=',
|
|
6951
|
-
left: {
|
|
6952
|
-
type: 'function',
|
|
6953
|
-
name: {
|
|
6954
|
-
name: [
|
|
6955
|
-
{
|
|
6956
|
-
type: 'default',
|
|
6957
|
-
value: 'YEAR',
|
|
6958
|
-
},
|
|
6959
|
-
],
|
|
6960
|
-
},
|
|
6961
|
-
args: {
|
|
6962
|
-
type: 'expr_list',
|
|
6963
|
-
value: [
|
|
6964
|
-
{
|
|
6965
|
-
type: 'column_ref',
|
|
6966
|
-
table: null,
|
|
6967
|
-
column: field,
|
|
6968
|
-
},
|
|
6969
|
-
],
|
|
6970
|
-
},
|
|
6971
|
-
over: null,
|
|
6972
|
-
},
|
|
6973
|
-
right: {
|
|
6974
|
-
type: 'function',
|
|
6975
|
-
name: {
|
|
6976
|
-
name: [
|
|
6977
|
-
{
|
|
6978
|
-
type: 'default',
|
|
6979
|
-
value: 'YEAR',
|
|
6980
|
-
},
|
|
6981
|
-
],
|
|
6982
|
-
},
|
|
6983
|
-
args: {
|
|
6984
|
-
type: 'expr_list',
|
|
6985
|
-
value: [
|
|
6986
|
-
{
|
|
6987
|
-
type: 'function',
|
|
6988
|
-
name: {
|
|
6989
|
-
name: [
|
|
6990
|
-
{
|
|
6991
|
-
type: 'default',
|
|
6992
|
-
value: 'CURRENT_DATE',
|
|
6993
|
-
},
|
|
6994
|
-
],
|
|
6995
|
-
},
|
|
6996
|
-
args: {
|
|
6997
|
-
type: 'expr_list',
|
|
6998
|
-
value: [],
|
|
6999
|
-
},
|
|
7000
|
-
over: null,
|
|
7001
|
-
},
|
|
7002
|
-
],
|
|
7003
|
-
},
|
|
7004
|
-
over: null,
|
|
7005
|
-
},
|
|
7006
|
-
},
|
|
7007
|
-
right: {
|
|
7008
|
-
type: 'binary_expr',
|
|
7009
|
-
operator: '=',
|
|
7010
|
-
left: {
|
|
7011
|
-
type: 'function',
|
|
7012
|
-
name: {
|
|
7013
|
-
name: [
|
|
7014
|
-
{
|
|
7015
|
-
type: 'default',
|
|
7016
|
-
value: 'QUARTER',
|
|
7017
|
-
},
|
|
7018
|
-
],
|
|
7019
|
-
},
|
|
7020
|
-
args: {
|
|
7021
|
-
type: 'expr_list',
|
|
7022
|
-
value: [
|
|
7023
|
-
{
|
|
7024
|
-
type: 'column_ref',
|
|
7025
|
-
table: null,
|
|
7026
|
-
column: field,
|
|
7027
|
-
},
|
|
7028
|
-
],
|
|
7029
|
-
},
|
|
7030
|
-
over: null,
|
|
7031
|
-
},
|
|
7032
|
-
right: {
|
|
7033
|
-
type: 'function',
|
|
7034
|
-
name: {
|
|
7035
|
-
name: [
|
|
7036
|
-
{
|
|
7037
|
-
type: 'default',
|
|
7038
|
-
value: 'QUARTER',
|
|
7039
|
-
},
|
|
7040
|
-
],
|
|
7041
|
-
},
|
|
7042
|
-
args: {
|
|
7043
|
-
type: 'expr_list',
|
|
7044
|
-
value: [
|
|
7045
|
-
{
|
|
7046
|
-
type: 'function',
|
|
7047
|
-
name: {
|
|
7048
|
-
name: [
|
|
7049
|
-
{
|
|
7050
|
-
type: 'default',
|
|
7051
|
-
value: 'CURRENT_DATE',
|
|
7052
|
-
},
|
|
7053
|
-
],
|
|
7054
|
-
},
|
|
7055
|
-
args: {
|
|
7056
|
-
type: 'expr_list',
|
|
7057
|
-
value: [],
|
|
7058
|
-
},
|
|
7059
|
-
over: null,
|
|
7060
|
-
},
|
|
7061
|
-
],
|
|
7062
|
-
},
|
|
7063
|
-
over: null,
|
|
7064
|
-
},
|
|
7065
|
-
},
|
|
7066
|
-
};
|
|
7067
|
-
case 'month':
|
|
7068
|
-
return {
|
|
7069
|
-
type: 'binary_expr',
|
|
7070
|
-
operator: 'AND',
|
|
7071
|
-
left: {
|
|
7072
|
-
type: 'binary_expr',
|
|
7073
|
-
operator: '=',
|
|
7074
|
-
left: {
|
|
7075
|
-
type: 'function',
|
|
7076
|
-
name: {
|
|
7077
|
-
name: [
|
|
7078
|
-
{
|
|
7079
|
-
type: 'default',
|
|
7080
|
-
value: 'YEAR',
|
|
7081
|
-
},
|
|
7082
|
-
],
|
|
7083
|
-
},
|
|
7084
|
-
args: {
|
|
7085
|
-
type: 'expr_list',
|
|
7086
|
-
value: [
|
|
7087
|
-
{
|
|
7088
|
-
type: 'column_ref',
|
|
7089
|
-
table: null,
|
|
7090
|
-
column: field,
|
|
7091
|
-
},
|
|
7092
|
-
],
|
|
7093
|
-
},
|
|
7094
|
-
over: null,
|
|
7095
|
-
},
|
|
7096
|
-
right: {
|
|
7097
|
-
type: 'function',
|
|
7098
|
-
name: {
|
|
7099
|
-
name: [
|
|
7100
|
-
{
|
|
7101
|
-
type: 'default',
|
|
7102
|
-
value: 'YEAR',
|
|
7103
|
-
},
|
|
7104
|
-
],
|
|
7105
|
-
},
|
|
7106
|
-
args: {
|
|
7107
|
-
type: 'expr_list',
|
|
7108
|
-
value: [
|
|
7109
|
-
{
|
|
7110
|
-
type: 'function',
|
|
7111
|
-
name: {
|
|
7112
|
-
name: [
|
|
7113
|
-
{
|
|
7114
|
-
type: 'default',
|
|
7115
|
-
value: 'CURRENT_DATE',
|
|
7116
|
-
},
|
|
7117
|
-
],
|
|
7118
|
-
},
|
|
7119
|
-
args: {
|
|
7120
|
-
type: 'expr_list',
|
|
7121
|
-
value: [],
|
|
7122
|
-
},
|
|
7123
|
-
over: null,
|
|
7124
|
-
},
|
|
7125
|
-
],
|
|
7126
|
-
},
|
|
7127
|
-
over: null,
|
|
7128
|
-
},
|
|
7129
|
-
},
|
|
7130
|
-
right: {
|
|
7131
|
-
type: 'binary_expr',
|
|
7132
|
-
operator: '=',
|
|
7133
|
-
left: {
|
|
7134
|
-
type: 'function',
|
|
7135
|
-
name: {
|
|
7136
|
-
name: [
|
|
7137
|
-
{
|
|
7138
|
-
type: 'default',
|
|
7139
|
-
value: 'MONTH',
|
|
7140
|
-
},
|
|
7141
|
-
],
|
|
7142
|
-
},
|
|
7143
|
-
args: {
|
|
7144
|
-
type: 'expr_list',
|
|
7145
|
-
value: [
|
|
7146
|
-
{
|
|
7147
|
-
type: 'column_ref',
|
|
7148
|
-
table: null,
|
|
7149
|
-
column: field,
|
|
7150
|
-
},
|
|
7151
|
-
],
|
|
7152
|
-
},
|
|
7153
|
-
over: null,
|
|
7154
|
-
},
|
|
7155
|
-
right: {
|
|
7156
|
-
type: 'function',
|
|
7157
|
-
name: {
|
|
7158
|
-
name: [
|
|
7159
|
-
{
|
|
7160
|
-
type: 'default',
|
|
7161
|
-
value: 'MONTH',
|
|
7162
|
-
},
|
|
7163
|
-
],
|
|
7164
|
-
},
|
|
7165
|
-
args: {
|
|
7166
|
-
type: 'expr_list',
|
|
7167
|
-
value: [
|
|
7168
|
-
{
|
|
7169
|
-
type: 'function',
|
|
7170
|
-
name: {
|
|
7171
|
-
name: [
|
|
7172
|
-
{
|
|
7173
|
-
type: 'default',
|
|
7174
|
-
value: 'CURRENT_DATE',
|
|
7175
|
-
},
|
|
7176
|
-
],
|
|
7177
|
-
},
|
|
7178
|
-
args: {
|
|
7179
|
-
type: 'expr_list',
|
|
7180
|
-
value: [],
|
|
7181
|
-
},
|
|
7182
|
-
over: null,
|
|
7183
|
-
},
|
|
7184
|
-
],
|
|
7185
|
-
},
|
|
7186
|
-
over: null,
|
|
7187
|
-
},
|
|
7188
|
-
},
|
|
7189
|
-
};
|
|
7190
|
-
case 'week':
|
|
7191
|
-
return {
|
|
7192
|
-
type: 'binary_expr',
|
|
7193
|
-
operator: 'AND',
|
|
7194
|
-
left: {
|
|
7195
|
-
type: 'binary_expr',
|
|
7196
|
-
operator: 'AND',
|
|
7197
|
-
left: {
|
|
7198
|
-
type: 'binary_expr',
|
|
7199
|
-
operator: '=',
|
|
7200
|
-
left: {
|
|
7201
|
-
type: 'function',
|
|
7202
|
-
name: {
|
|
7203
|
-
name: [
|
|
7204
|
-
{
|
|
7205
|
-
type: 'default',
|
|
7206
|
-
value: 'YEAR',
|
|
7207
|
-
},
|
|
7208
|
-
],
|
|
7209
|
-
},
|
|
7210
|
-
args: {
|
|
7211
|
-
type: 'expr_list',
|
|
7212
|
-
value: [
|
|
7213
|
-
{
|
|
7214
|
-
type: 'column_ref',
|
|
7215
|
-
table: null,
|
|
7216
|
-
column: field,
|
|
7217
|
-
},
|
|
7218
|
-
],
|
|
7219
|
-
},
|
|
7220
|
-
over: null,
|
|
7221
|
-
},
|
|
7222
|
-
right: {
|
|
7223
|
-
type: 'function',
|
|
7224
|
-
name: {
|
|
7225
|
-
name: [
|
|
7226
|
-
{
|
|
7227
|
-
type: 'default',
|
|
7228
|
-
value: 'YEAR',
|
|
7229
|
-
},
|
|
7230
|
-
],
|
|
7231
|
-
},
|
|
7232
|
-
args: {
|
|
7233
|
-
type: 'expr_list',
|
|
7234
|
-
value: [
|
|
7235
|
-
{
|
|
7236
|
-
type: 'function',
|
|
7237
|
-
name: {
|
|
7238
|
-
name: [
|
|
7239
|
-
{
|
|
7240
|
-
type: 'default',
|
|
7241
|
-
value: 'CURRENT_DATE',
|
|
7242
|
-
},
|
|
7243
|
-
],
|
|
7244
|
-
},
|
|
7245
|
-
args: {
|
|
7246
|
-
type: 'expr_list',
|
|
7247
|
-
value: [],
|
|
7248
|
-
},
|
|
7249
|
-
over: null,
|
|
7250
|
-
},
|
|
7251
|
-
],
|
|
7252
|
-
},
|
|
7253
|
-
over: null,
|
|
7254
|
-
},
|
|
7255
|
-
},
|
|
7256
|
-
right: {
|
|
7257
|
-
type: 'binary_expr',
|
|
7258
|
-
operator: '=',
|
|
7259
|
-
left: {
|
|
7260
|
-
type: 'function',
|
|
7261
|
-
name: {
|
|
7262
|
-
name: [
|
|
7263
|
-
{
|
|
7264
|
-
type: 'default',
|
|
7265
|
-
value: 'MONTH',
|
|
7266
|
-
},
|
|
7267
|
-
],
|
|
7268
|
-
},
|
|
7269
|
-
args: {
|
|
7270
|
-
type: 'expr_list',
|
|
7271
|
-
value: [
|
|
7272
|
-
{
|
|
7273
|
-
type: 'column_ref',
|
|
7274
|
-
table: null,
|
|
7275
|
-
column: field,
|
|
7276
|
-
},
|
|
7277
|
-
],
|
|
7278
|
-
},
|
|
7279
|
-
over: null,
|
|
7280
|
-
},
|
|
7281
|
-
right: {
|
|
7282
|
-
type: 'function',
|
|
7283
|
-
name: {
|
|
7284
|
-
name: [
|
|
7285
|
-
{
|
|
7286
|
-
type: 'default',
|
|
7287
|
-
value: 'MONTH',
|
|
7288
|
-
},
|
|
7289
|
-
],
|
|
7290
|
-
},
|
|
7291
|
-
args: {
|
|
7292
|
-
type: 'expr_list',
|
|
7293
|
-
value: [
|
|
7294
|
-
{
|
|
7295
|
-
type: 'function',
|
|
7296
|
-
name: {
|
|
7297
|
-
name: [
|
|
7298
|
-
{
|
|
7299
|
-
type: 'default',
|
|
7300
|
-
value: 'CURRENT_DATE',
|
|
7301
|
-
},
|
|
7302
|
-
],
|
|
7303
|
-
},
|
|
7304
|
-
args: {
|
|
7305
|
-
type: 'expr_list',
|
|
7306
|
-
value: [],
|
|
7307
|
-
},
|
|
7308
|
-
over: null,
|
|
7309
|
-
},
|
|
7310
|
-
],
|
|
7311
|
-
},
|
|
7312
|
-
over: null,
|
|
7313
|
-
},
|
|
7314
|
-
},
|
|
7315
|
-
},
|
|
7316
|
-
right: {
|
|
7317
|
-
type: 'binary_expr',
|
|
7318
|
-
operator: '=',
|
|
7319
|
-
left: {
|
|
7320
|
-
type: 'function',
|
|
7321
|
-
name: {
|
|
7322
|
-
name: [
|
|
7323
|
-
{
|
|
7324
|
-
type: 'default',
|
|
7325
|
-
value: 'WEEK',
|
|
7326
|
-
},
|
|
7327
|
-
],
|
|
7328
|
-
},
|
|
7329
|
-
args: {
|
|
7330
|
-
type: 'expr_list',
|
|
7331
|
-
value: [
|
|
7332
|
-
{
|
|
7333
|
-
type: 'column_ref',
|
|
7334
|
-
table: null,
|
|
7335
|
-
column: field,
|
|
7336
|
-
},
|
|
7337
|
-
],
|
|
7338
|
-
},
|
|
7339
|
-
over: null,
|
|
7340
|
-
},
|
|
7341
|
-
right: {
|
|
7342
|
-
type: 'function',
|
|
7343
|
-
name: {
|
|
7344
|
-
name: [
|
|
7345
|
-
{
|
|
7346
|
-
type: 'default',
|
|
7347
|
-
value: 'WEEK',
|
|
7348
|
-
},
|
|
7349
|
-
],
|
|
7350
|
-
},
|
|
7351
|
-
args: {
|
|
7352
|
-
type: 'expr_list',
|
|
7353
|
-
value: [
|
|
7354
|
-
{
|
|
7355
|
-
type: 'function',
|
|
7356
|
-
name: {
|
|
7357
|
-
name: [
|
|
7358
|
-
{
|
|
7359
|
-
type: 'default',
|
|
7360
|
-
value: 'CURRENT_DATE',
|
|
7361
|
-
},
|
|
7362
|
-
],
|
|
7363
|
-
},
|
|
7364
|
-
args: {
|
|
7365
|
-
type: 'expr_list',
|
|
7366
|
-
value: [],
|
|
7367
|
-
},
|
|
7368
|
-
over: null,
|
|
7369
|
-
},
|
|
7370
|
-
],
|
|
7371
|
-
},
|
|
7372
|
-
over: null,
|
|
7373
|
-
},
|
|
7374
|
-
},
|
|
7375
|
-
};
|
|
7376
|
-
case 'day':
|
|
7377
|
-
return {
|
|
7378
|
-
type: 'binary_expr',
|
|
7379
|
-
operator: 'AND',
|
|
7380
|
-
left: {
|
|
7381
|
-
type: 'binary_expr',
|
|
7382
|
-
operator: 'AND',
|
|
7383
|
-
left: {
|
|
7384
|
-
type: 'binary_expr',
|
|
7385
|
-
operator: '=',
|
|
7386
|
-
left: {
|
|
7387
|
-
type: 'function',
|
|
7388
|
-
name: {
|
|
7389
|
-
name: [
|
|
7390
|
-
{
|
|
7391
|
-
type: 'default',
|
|
7392
|
-
value: 'YEAR',
|
|
7393
|
-
},
|
|
7394
|
-
],
|
|
7395
|
-
},
|
|
7396
|
-
args: {
|
|
7397
|
-
type: 'expr_list',
|
|
7398
|
-
value: [
|
|
7399
|
-
{
|
|
7400
|
-
type: 'column_ref',
|
|
7401
|
-
table: null,
|
|
7402
|
-
column: field,
|
|
7403
|
-
},
|
|
7404
|
-
],
|
|
7405
|
-
},
|
|
7406
|
-
over: null,
|
|
7407
|
-
},
|
|
7408
|
-
right: {
|
|
7409
|
-
type: 'function',
|
|
7410
|
-
name: {
|
|
7411
|
-
name: [
|
|
7412
|
-
{
|
|
7413
|
-
type: 'default',
|
|
7414
|
-
value: 'YEAR',
|
|
7415
|
-
},
|
|
7416
|
-
],
|
|
7417
|
-
},
|
|
7418
|
-
args: {
|
|
7419
|
-
type: 'expr_list',
|
|
7420
|
-
value: [
|
|
7421
|
-
{
|
|
7422
|
-
type: 'function',
|
|
7423
|
-
name: {
|
|
7424
|
-
name: [
|
|
7425
|
-
{
|
|
7426
|
-
type: 'default',
|
|
7427
|
-
value: 'CURRENT_DATE',
|
|
7428
|
-
},
|
|
7429
|
-
],
|
|
7430
|
-
},
|
|
7431
|
-
args: {
|
|
7432
|
-
type: 'expr_list',
|
|
7433
|
-
value: [],
|
|
7434
|
-
},
|
|
7435
|
-
over: null,
|
|
7436
|
-
},
|
|
7437
|
-
],
|
|
7438
|
-
},
|
|
7439
|
-
over: null,
|
|
7440
|
-
},
|
|
7441
|
-
},
|
|
7442
|
-
right: {
|
|
7443
|
-
type: 'binary_expr',
|
|
7444
|
-
operator: '=',
|
|
7445
|
-
left: {
|
|
7446
|
-
type: 'function',
|
|
7447
|
-
name: {
|
|
7448
|
-
name: [
|
|
7449
|
-
{
|
|
7450
|
-
type: 'default',
|
|
7451
|
-
value: 'MONTH',
|
|
7452
|
-
},
|
|
7453
|
-
],
|
|
7454
|
-
},
|
|
7455
|
-
args: {
|
|
7456
|
-
type: 'expr_list',
|
|
7457
|
-
value: [
|
|
7458
|
-
{
|
|
7459
|
-
type: 'column_ref',
|
|
7460
|
-
table: null,
|
|
7461
|
-
column: field,
|
|
7462
|
-
},
|
|
7463
|
-
],
|
|
7464
|
-
},
|
|
7465
|
-
over: null,
|
|
7466
|
-
},
|
|
7467
|
-
right: {
|
|
7468
|
-
type: 'function',
|
|
7469
|
-
name: {
|
|
7470
|
-
name: [
|
|
7471
|
-
{
|
|
7472
|
-
type: 'default',
|
|
7473
|
-
value: 'MONTH',
|
|
7474
|
-
},
|
|
7475
|
-
],
|
|
7476
|
-
},
|
|
7477
|
-
args: {
|
|
7478
|
-
type: 'expr_list',
|
|
7479
|
-
value: [
|
|
7480
|
-
{
|
|
7481
|
-
type: 'function',
|
|
7482
|
-
name: {
|
|
7483
|
-
name: [
|
|
7484
|
-
{
|
|
7485
|
-
type: 'default',
|
|
7486
|
-
value: 'CURRENT_DATE',
|
|
7487
|
-
},
|
|
7488
|
-
],
|
|
7489
|
-
},
|
|
7490
|
-
args: {
|
|
7491
|
-
type: 'expr_list',
|
|
7492
|
-
value: [],
|
|
7493
|
-
},
|
|
7494
|
-
over: null,
|
|
7495
|
-
},
|
|
7496
|
-
],
|
|
7497
|
-
},
|
|
7498
|
-
over: null,
|
|
7499
|
-
},
|
|
7500
|
-
},
|
|
7501
|
-
},
|
|
7502
|
-
right: {
|
|
7503
|
-
type: 'binary_expr',
|
|
7504
|
-
operator: '=',
|
|
7505
|
-
left: {
|
|
7506
|
-
type: 'function',
|
|
7507
|
-
name: {
|
|
7508
|
-
name: [
|
|
7509
|
-
{
|
|
7510
|
-
type: 'default',
|
|
7511
|
-
value: 'DAY',
|
|
7512
|
-
},
|
|
7513
|
-
],
|
|
7514
|
-
},
|
|
7515
|
-
args: {
|
|
7516
|
-
type: 'expr_list',
|
|
7517
|
-
value: [
|
|
7518
|
-
{
|
|
7519
|
-
type: 'column_ref',
|
|
7520
|
-
table: null,
|
|
7521
|
-
column: field,
|
|
7522
|
-
},
|
|
7523
|
-
],
|
|
7524
|
-
},
|
|
7525
|
-
over: null,
|
|
7526
|
-
},
|
|
7527
|
-
right: {
|
|
7528
|
-
type: 'function',
|
|
7529
|
-
name: {
|
|
7530
|
-
name: [
|
|
7531
|
-
{
|
|
7532
|
-
type: 'default',
|
|
7533
|
-
value: 'DAY',
|
|
7534
|
-
},
|
|
7535
|
-
],
|
|
7536
|
-
},
|
|
7537
|
-
args: {
|
|
7538
|
-
type: 'expr_list',
|
|
7539
|
-
value: [
|
|
7540
|
-
{
|
|
7541
|
-
type: 'function',
|
|
7542
|
-
name: {
|
|
7543
|
-
name: [
|
|
7544
|
-
{
|
|
7545
|
-
type: 'default',
|
|
7546
|
-
value: 'CURRENT_DATE',
|
|
7547
|
-
},
|
|
7548
|
-
],
|
|
7549
|
-
},
|
|
7550
|
-
args: {
|
|
7551
|
-
type: 'expr_list',
|
|
7552
|
-
value: [],
|
|
7553
|
-
},
|
|
7554
|
-
over: null,
|
|
7555
|
-
},
|
|
7556
|
-
],
|
|
7557
|
-
},
|
|
7558
|
-
over: null,
|
|
7025
|
+
},
|
|
7026
|
+
parentheses: true,
|
|
7027
|
+
};
|
|
7028
|
+
}
|
|
7029
|
+
let unitFormat;
|
|
7030
|
+
switch (filter.value.unit) {
|
|
7031
|
+
case 'year': {
|
|
7032
|
+
unitFormat = '%Y';
|
|
7033
|
+
break;
|
|
7034
|
+
}
|
|
7035
|
+
case 'month': {
|
|
7036
|
+
unitFormat = '%Y-%m';
|
|
7037
|
+
break;
|
|
7038
|
+
}
|
|
7039
|
+
case 'week': {
|
|
7040
|
+
unitFormat = '%Y-%u';
|
|
7041
|
+
break;
|
|
7042
|
+
}
|
|
7043
|
+
case 'day': {
|
|
7044
|
+
unitFormat = '%Y-%m-%d';
|
|
7045
|
+
break;
|
|
7046
|
+
}
|
|
7047
|
+
case 'hour': {
|
|
7048
|
+
unitFormat = '%Y-%m-%d %H';
|
|
7049
|
+
break;
|
|
7050
|
+
}
|
|
7051
|
+
default: {
|
|
7052
|
+
console.error('Unknown unit: ', filter.value.unit);
|
|
7053
|
+
unitFormat = '%Y';
|
|
7054
|
+
}
|
|
7055
|
+
}
|
|
7056
|
+
return {
|
|
7057
|
+
type: 'binary_expr',
|
|
7058
|
+
operator: '=',
|
|
7059
|
+
left: {
|
|
7060
|
+
type: 'function',
|
|
7061
|
+
name: {
|
|
7062
|
+
name: [
|
|
7063
|
+
{
|
|
7064
|
+
type: 'default',
|
|
7065
|
+
value: 'DATE_FORMAT',
|
|
7559
7066
|
},
|
|
7560
|
-
|
|
7561
|
-
}
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
left: {
|
|
7573
|
-
type: 'binary_expr',
|
|
7574
|
-
operator: '=',
|
|
7575
|
-
left: {
|
|
7576
|
-
type: 'function',
|
|
7577
|
-
name: {
|
|
7578
|
-
name: [
|
|
7579
|
-
{
|
|
7580
|
-
type: 'default',
|
|
7581
|
-
value: 'YEAR',
|
|
7582
|
-
},
|
|
7583
|
-
],
|
|
7584
|
-
},
|
|
7585
|
-
args: {
|
|
7586
|
-
type: 'expr_list',
|
|
7587
|
-
value: [
|
|
7588
|
-
{
|
|
7589
|
-
type: 'column_ref',
|
|
7590
|
-
table: null,
|
|
7591
|
-
column: field,
|
|
7592
|
-
},
|
|
7593
|
-
],
|
|
7594
|
-
},
|
|
7595
|
-
over: null,
|
|
7596
|
-
},
|
|
7597
|
-
right: {
|
|
7598
|
-
type: 'function',
|
|
7599
|
-
name: {
|
|
7600
|
-
name: [
|
|
7601
|
-
{
|
|
7602
|
-
type: 'default',
|
|
7603
|
-
value: 'YEAR',
|
|
7604
|
-
},
|
|
7605
|
-
],
|
|
7606
|
-
},
|
|
7607
|
-
args: {
|
|
7608
|
-
type: 'expr_list',
|
|
7609
|
-
value: [
|
|
7610
|
-
{
|
|
7611
|
-
type: 'function',
|
|
7612
|
-
name: {
|
|
7613
|
-
name: [
|
|
7614
|
-
{
|
|
7615
|
-
type: 'default',
|
|
7616
|
-
value: 'CURRENT_TIMESTAMP',
|
|
7617
|
-
},
|
|
7618
|
-
],
|
|
7619
|
-
},
|
|
7620
|
-
args: {
|
|
7621
|
-
type: 'expr_list',
|
|
7622
|
-
value: [],
|
|
7623
|
-
},
|
|
7624
|
-
over: null,
|
|
7625
|
-
},
|
|
7626
|
-
],
|
|
7627
|
-
},
|
|
7628
|
-
over: null,
|
|
7629
|
-
},
|
|
7630
|
-
},
|
|
7631
|
-
right: {
|
|
7632
|
-
type: 'binary_expr',
|
|
7633
|
-
operator: '=',
|
|
7634
|
-
left: {
|
|
7635
|
-
type: 'function',
|
|
7636
|
-
name: {
|
|
7637
|
-
name: [
|
|
7638
|
-
{
|
|
7639
|
-
type: 'default',
|
|
7640
|
-
value: 'MONTH',
|
|
7641
|
-
},
|
|
7642
|
-
],
|
|
7643
|
-
},
|
|
7644
|
-
args: {
|
|
7645
|
-
type: 'expr_list',
|
|
7646
|
-
value: [
|
|
7647
|
-
{
|
|
7648
|
-
type: 'column_ref',
|
|
7649
|
-
table: null,
|
|
7650
|
-
column: field,
|
|
7651
|
-
},
|
|
7652
|
-
],
|
|
7653
|
-
},
|
|
7654
|
-
over: null,
|
|
7655
|
-
},
|
|
7656
|
-
right: {
|
|
7657
|
-
type: 'function',
|
|
7658
|
-
name: {
|
|
7659
|
-
name: [
|
|
7660
|
-
{
|
|
7661
|
-
type: 'default',
|
|
7662
|
-
value: 'MONTH',
|
|
7663
|
-
},
|
|
7664
|
-
],
|
|
7665
|
-
},
|
|
7666
|
-
args: {
|
|
7667
|
-
type: 'expr_list',
|
|
7668
|
-
value: [
|
|
7669
|
-
{
|
|
7670
|
-
type: 'function',
|
|
7671
|
-
name: {
|
|
7672
|
-
name: [
|
|
7673
|
-
{
|
|
7674
|
-
type: 'default',
|
|
7675
|
-
value: 'CURRENT_TIMESTAMP',
|
|
7676
|
-
},
|
|
7677
|
-
],
|
|
7678
|
-
},
|
|
7679
|
-
args: {
|
|
7680
|
-
type: 'expr_list',
|
|
7681
|
-
value: [],
|
|
7682
|
-
},
|
|
7683
|
-
over: null,
|
|
7684
|
-
},
|
|
7685
|
-
],
|
|
7686
|
-
},
|
|
7687
|
-
over: null,
|
|
7067
|
+
],
|
|
7068
|
+
},
|
|
7069
|
+
args: {
|
|
7070
|
+
type: 'expr_list',
|
|
7071
|
+
value: [
|
|
7072
|
+
{
|
|
7073
|
+
type: 'column_ref',
|
|
7074
|
+
table: null,
|
|
7075
|
+
column: {
|
|
7076
|
+
expr: {
|
|
7077
|
+
type: 'default',
|
|
7078
|
+
value: field,
|
|
7688
7079
|
},
|
|
7689
7080
|
},
|
|
7690
7081
|
},
|
|
7691
|
-
|
|
7692
|
-
type: '
|
|
7693
|
-
|
|
7694
|
-
left: {
|
|
7695
|
-
type: 'function',
|
|
7696
|
-
name: {
|
|
7697
|
-
name: [
|
|
7698
|
-
{
|
|
7699
|
-
type: 'default',
|
|
7700
|
-
value: 'DAY',
|
|
7701
|
-
},
|
|
7702
|
-
],
|
|
7703
|
-
},
|
|
7704
|
-
args: {
|
|
7705
|
-
type: 'expr_list',
|
|
7706
|
-
value: [
|
|
7707
|
-
{
|
|
7708
|
-
type: 'column_ref',
|
|
7709
|
-
table: null,
|
|
7710
|
-
column: field,
|
|
7711
|
-
},
|
|
7712
|
-
],
|
|
7713
|
-
},
|
|
7714
|
-
over: null,
|
|
7715
|
-
},
|
|
7716
|
-
right: {
|
|
7717
|
-
type: 'function',
|
|
7718
|
-
name: {
|
|
7719
|
-
name: [
|
|
7720
|
-
{
|
|
7721
|
-
type: 'default',
|
|
7722
|
-
value: 'DAY',
|
|
7723
|
-
},
|
|
7724
|
-
],
|
|
7725
|
-
},
|
|
7726
|
-
args: {
|
|
7727
|
-
type: 'expr_list',
|
|
7728
|
-
value: [
|
|
7729
|
-
{
|
|
7730
|
-
type: 'function',
|
|
7731
|
-
name: {
|
|
7732
|
-
name: [
|
|
7733
|
-
{
|
|
7734
|
-
type: 'default',
|
|
7735
|
-
value: 'CURRENT_TIMESTAMP',
|
|
7736
|
-
},
|
|
7737
|
-
],
|
|
7738
|
-
},
|
|
7739
|
-
args: {
|
|
7740
|
-
type: 'expr_list',
|
|
7741
|
-
value: [],
|
|
7742
|
-
},
|
|
7743
|
-
over: null,
|
|
7744
|
-
},
|
|
7745
|
-
],
|
|
7746
|
-
},
|
|
7747
|
-
over: null,
|
|
7748
|
-
},
|
|
7082
|
+
{
|
|
7083
|
+
type: 'single_quote_string',
|
|
7084
|
+
value: unitFormat,
|
|
7749
7085
|
},
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
value: 'HOUR',
|
|
7761
|
-
},
|
|
7762
|
-
],
|
|
7763
|
-
},
|
|
7764
|
-
args: {
|
|
7765
|
-
type: 'expr_list',
|
|
7766
|
-
value: [
|
|
7767
|
-
{
|
|
7768
|
-
type: 'column_ref',
|
|
7769
|
-
table: null,
|
|
7770
|
-
column: field,
|
|
7771
|
-
},
|
|
7772
|
-
],
|
|
7773
|
-
},
|
|
7774
|
-
over: null,
|
|
7086
|
+
],
|
|
7087
|
+
},
|
|
7088
|
+
},
|
|
7089
|
+
right: {
|
|
7090
|
+
type: 'function',
|
|
7091
|
+
name: {
|
|
7092
|
+
name: [
|
|
7093
|
+
{
|
|
7094
|
+
type: 'default',
|
|
7095
|
+
value: 'DATE_FORMAT',
|
|
7775
7096
|
},
|
|
7776
|
-
|
|
7097
|
+
],
|
|
7098
|
+
},
|
|
7099
|
+
args: {
|
|
7100
|
+
type: 'expr_list',
|
|
7101
|
+
value: [
|
|
7102
|
+
{
|
|
7777
7103
|
type: 'function',
|
|
7778
7104
|
name: {
|
|
7779
7105
|
name: [
|
|
7780
7106
|
{
|
|
7781
|
-
type: '
|
|
7782
|
-
value: '
|
|
7107
|
+
type: 'origin',
|
|
7108
|
+
value: 'CURRENT_DATE',
|
|
7783
7109
|
},
|
|
7784
7110
|
],
|
|
7785
7111
|
},
|
|
7786
7112
|
args: {
|
|
7787
7113
|
type: 'expr_list',
|
|
7788
|
-
value: [
|
|
7789
|
-
{
|
|
7790
|
-
type: 'function',
|
|
7791
|
-
name: {
|
|
7792
|
-
name: [
|
|
7793
|
-
{
|
|
7794
|
-
type: 'default',
|
|
7795
|
-
value: 'CURRENT_TIMESTAMP',
|
|
7796
|
-
},
|
|
7797
|
-
],
|
|
7798
|
-
},
|
|
7799
|
-
args: {
|
|
7800
|
-
type: 'expr_list',
|
|
7801
|
-
value: [],
|
|
7802
|
-
},
|
|
7803
|
-
over: null,
|
|
7804
|
-
},
|
|
7805
|
-
],
|
|
7114
|
+
value: [],
|
|
7806
7115
|
},
|
|
7807
7116
|
over: null,
|
|
7808
7117
|
},
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7118
|
+
{
|
|
7119
|
+
type: 'single_quote_string',
|
|
7120
|
+
value: unitFormat,
|
|
7121
|
+
},
|
|
7122
|
+
],
|
|
7123
|
+
},
|
|
7124
|
+
},
|
|
7125
|
+
};
|
|
7126
|
+
}
|
|
7815
7127
|
case 'postgresql':
|
|
7816
7128
|
return {
|
|
7817
7129
|
type: 'binary_expr',
|
|
@@ -8007,6 +7319,7 @@ const filterToAst = (filter, db) => {
|
|
|
8007
7319
|
},
|
|
8008
7320
|
},
|
|
8009
7321
|
},
|
|
7322
|
+
parentheses: true,
|
|
8010
7323
|
};
|
|
8011
7324
|
case 'snowflake':
|
|
8012
7325
|
return {
|
|
@@ -8090,6 +7403,7 @@ const filterToAst = (filter, db) => {
|
|
|
8090
7403
|
},
|
|
8091
7404
|
},
|
|
8092
7405
|
},
|
|
7406
|
+
parentheses: true,
|
|
8093
7407
|
};
|
|
8094
7408
|
case 'bigquery':
|
|
8095
7409
|
return {
|
|
@@ -8229,6 +7543,7 @@ const filterToAst = (filter, db) => {
|
|
|
8229
7543
|
over: null,
|
|
8230
7544
|
},
|
|
8231
7545
|
},
|
|
7546
|
+
parentheses: true,
|
|
8232
7547
|
};
|
|
8233
7548
|
case 'mysql':
|
|
8234
7549
|
return {
|
|
@@ -8312,6 +7627,7 @@ const filterToAst = (filter, db) => {
|
|
|
8312
7627
|
},
|
|
8313
7628
|
},
|
|
8314
7629
|
},
|
|
7630
|
+
parentheses: true,
|
|
8315
7631
|
};
|
|
8316
7632
|
case 'postgresql':
|
|
8317
7633
|
return {
|
|
@@ -8397,6 +7713,7 @@ const filterToAst = (filter, db) => {
|
|
|
8397
7713
|
},
|
|
8398
7714
|
},
|
|
8399
7715
|
},
|
|
7716
|
+
parentheses: true,
|
|
8400
7717
|
};
|
|
8401
7718
|
default:
|
|
8402
7719
|
console.error('Unknown database source: ', db);
|