@quillsql/react 2.13.51 → 2.13.53

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.
Files changed (49) hide show
  1. package/dist/cjs/ChartBuilder.d.ts.map +1 -1
  2. package/dist/cjs/ChartBuilder.js +12 -6
  3. package/dist/cjs/Context.d.ts +4 -1
  4. package/dist/cjs/Context.d.ts.map +1 -1
  5. package/dist/cjs/Context.js +67 -44
  6. package/dist/cjs/Dashboard.d.ts +1 -1
  7. package/dist/cjs/Dashboard.d.ts.map +1 -1
  8. package/dist/cjs/Dashboard.js +37 -15
  9. package/dist/cjs/QuillProvider.d.ts +1 -1
  10. package/dist/cjs/QuillProvider.d.ts.map +1 -1
  11. package/dist/cjs/QuillProvider.js +3 -0
  12. package/dist/cjs/ReportBuilder.js +1 -1
  13. package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
  14. package/dist/cjs/utils/astFilterProcessing.js +681 -122
  15. package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
  16. package/dist/cjs/utils/columnProcessing.js +1 -0
  17. package/dist/cjs/utils/pivotConstructor.js +2 -2
  18. package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
  19. package/dist/cjs/utils/queryConstructor.js +28 -0
  20. package/dist/cjs/utils/report.d.ts.map +1 -1
  21. package/dist/cjs/utils/report.js +1 -1
  22. package/dist/cjs/utils/tableProcessing.d.ts +11 -7
  23. package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
  24. package/dist/cjs/utils/tableProcessing.js +10 -11
  25. package/dist/esm/ChartBuilder.d.ts.map +1 -1
  26. package/dist/esm/ChartBuilder.js +12 -6
  27. package/dist/esm/Context.d.ts +4 -1
  28. package/dist/esm/Context.d.ts.map +1 -1
  29. package/dist/esm/Context.js +67 -44
  30. package/dist/esm/Dashboard.d.ts +1 -1
  31. package/dist/esm/Dashboard.d.ts.map +1 -1
  32. package/dist/esm/Dashboard.js +37 -15
  33. package/dist/esm/QuillProvider.d.ts +1 -1
  34. package/dist/esm/QuillProvider.d.ts.map +1 -1
  35. package/dist/esm/QuillProvider.js +3 -0
  36. package/dist/esm/ReportBuilder.js +1 -1
  37. package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
  38. package/dist/esm/utils/astFilterProcessing.js +681 -122
  39. package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
  40. package/dist/esm/utils/columnProcessing.js +1 -0
  41. package/dist/esm/utils/pivotConstructor.js +2 -2
  42. package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
  43. package/dist/esm/utils/queryConstructor.js +28 -0
  44. package/dist/esm/utils/report.d.ts.map +1 -1
  45. package/dist/esm/utils/report.js +1 -1
  46. package/dist/esm/utils/tableProcessing.d.ts +11 -7
  47. package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
  48. package/dist/esm/utils/tableProcessing.js +10 -11
  49. package/package.json +1 -1
@@ -3142,6 +3142,109 @@ const queryPatterns = [
3142
3142
  },
3143
3143
  },
3144
3144
  ],
3145
+ // TODO: Add databricks
3146
+ // using postgresql cases for now
3147
+ databricks: [
3148
+ {
3149
+ query: `
3150
+ SELECT *
3151
+ FROM transactions
3152
+ WHERE transaction_date >= CURRENT_DATE - INTERVAL '30 months'
3153
+ `,
3154
+ value: function (astWhere) {
3155
+ const value = astWhere.right?.right?.expr?.value ?? null;
3156
+ if (astWhere.right?.right?.expr?.type !== 'number') {
3157
+ return value ? Number(value.split(' ')[0]) : null;
3158
+ }
3159
+ else {
3160
+ return value;
3161
+ }
3162
+ },
3163
+ unit: function (astWhere) {
3164
+ const unit = astWhere.right?.right?.unit ?? null;
3165
+ if (unit === '') {
3166
+ return stripTimeS(astWhere.right?.right?.expr?.value?.split(' ')[1]);
3167
+ }
3168
+ else {
3169
+ return unit;
3170
+ }
3171
+ },
3172
+ ast: {
3173
+ with: null,
3174
+ type: 'select',
3175
+ options: null,
3176
+ distinct: {
3177
+ type: null,
3178
+ },
3179
+ columns: [
3180
+ {
3181
+ expr: {
3182
+ type: 'column_ref',
3183
+ table: null,
3184
+ column: '*',
3185
+ },
3186
+ as: null,
3187
+ },
3188
+ ],
3189
+ into: {
3190
+ position: null,
3191
+ },
3192
+ from: [
3193
+ {
3194
+ db: null,
3195
+ table: 'transactions',
3196
+ as: null,
3197
+ },
3198
+ ],
3199
+ where: {
3200
+ type: 'binary_expr',
3201
+ operator: '>=',
3202
+ left: {
3203
+ type: 'column_ref',
3204
+ table: null,
3205
+ column: {
3206
+ expr: {
3207
+ type: 'default',
3208
+ value: 'transaction_date',
3209
+ },
3210
+ },
3211
+ },
3212
+ right: {
3213
+ type: 'binary_expr',
3214
+ operator: '-',
3215
+ left: {
3216
+ type: 'function',
3217
+ name: {
3218
+ name: [
3219
+ {
3220
+ type: 'origin',
3221
+ value: 'CURRENT_DATE',
3222
+ },
3223
+ ],
3224
+ },
3225
+ over: null,
3226
+ },
3227
+ right: {
3228
+ type: 'interval',
3229
+ expr: {
3230
+ type: 'single_quote_string',
3231
+ value: '30 months',
3232
+ },
3233
+ unit: '',
3234
+ },
3235
+ },
3236
+ },
3237
+ groupby: null,
3238
+ having: null,
3239
+ orderby: null,
3240
+ limit: {
3241
+ seperator: '',
3242
+ value: [],
3243
+ },
3244
+ window: null,
3245
+ },
3246
+ },
3247
+ ],
3145
3248
  },
3146
3249
  },
3147
3250
  {
@@ -6195,56 +6298,19 @@ const queryPatterns = [
6195
6298
  },
6196
6299
  },
6197
6300
  ],
6198
- },
6199
- },
6200
- {
6201
- operator: Filter_1.DateOperator.InThePrevious,
6202
- patterns: {
6203
- redshift: [
6301
+ // TODO: Add databricks
6302
+ // using postgresql cases for now
6303
+ databricks: [
6204
6304
  {
6205
6305
  query: `
6206
- SELECT * FROM transactions
6207
- WHERE transaction_date >= DATEADD(day, -180, CURRENT_DATE)
6208
- AND transaction_date < DATEADD(day, -90, CURRENT_DATE)
6306
+ SELECT * FROM transactions
6307
+ WHERE DATE_TRUNC('month', transaction_date) = DATE_TRUNC('month', CURRENT_DATE)
6209
6308
  `,
6210
- value: function (astWhere) {
6211
- if (astWhere.right.operator === 'AND') {
6212
- // Avoid AND chains
6213
- return -1;
6214
- }
6215
- const operatorLeft = astWhere.left.operator;
6216
- const operatorRight = astWhere.right.operator;
6217
- const valueLeft = -astWhere.left.right?.args?.value[1]?.value;
6218
- const valueRight = -astWhere.right.right?.args?.value[1]?.value;
6219
- if (!valueLeft || !valueRight) {
6220
- return null;
6221
- }
6222
- if (operatorLeft === '>=' &&
6223
- operatorRight === '<' &&
6224
- valueLeft == valueRight * 2) {
6225
- return valueRight;
6226
- }
6227
- else if (operatorLeft === '<' &&
6228
- operatorRight === '>=' &&
6229
- valueLeft * 2 == valueRight) {
6230
- return valueLeft;
6231
- }
6232
- else {
6233
- const unitLeft = astWhere.left?.right?.args?.value[0]?.column?.expr?.value ??
6234
- null;
6235
- const unitRight = astWhere.right?.right?.args?.value[0]?.column?.expr?.value ??
6236
- null;
6237
- return parseStartEndDate(operatorLeft, operatorRight, valueLeft, valueRight, stripTimeS(unitLeft.toLowerCase()), stripTimeS(unitRight.toLowerCase()));
6238
- }
6309
+ value: function () {
6310
+ return 0;
6239
6311
  },
6240
6312
  unit: function (astWhere) {
6241
- const unitLeft = astWhere.left?.right?.args?.value[0]?.column?.expr?.value ?? null;
6242
- const unitRight = astWhere.right?.right?.args?.value[0]?.column?.expr?.value ??
6243
- null;
6244
- return stripTimeS(unitLeft.toLowerCase()) ===
6245
- stripTimeS(unitRight.toLowerCase())
6246
- ? stripTimeS(unitLeft.toLowerCase())
6247
- : null;
6313
+ return astWhere.left?.args?.value[0]?.value ?? null;
6248
6314
  },
6249
6315
  ast: {
6250
6316
  with: null,
@@ -6275,95 +6341,408 @@ const queryPatterns = [
6275
6341
  ],
6276
6342
  where: {
6277
6343
  type: 'binary_expr',
6278
- operator: 'AND',
6344
+ operator: '=',
6279
6345
  left: {
6280
- type: 'binary_expr',
6281
- operator: '>=',
6282
- left: {
6283
- type: 'column_ref',
6284
- table: null,
6285
- column: {
6286
- expr: {
6346
+ type: 'function',
6347
+ name: {
6348
+ name: [
6349
+ {
6287
6350
  type: 'default',
6288
- value: 'transaction_date',
6351
+ value: 'DATE_TRUNC',
6289
6352
  },
6290
- },
6353
+ ],
6291
6354
  },
6292
- right: {
6293
- type: 'function',
6294
- name: {
6295
- name: [
6296
- {
6297
- type: 'default',
6298
- value: 'DATEADD',
6299
- },
6300
- ],
6301
- },
6302
- args: {
6303
- type: 'expr_list',
6304
- value: [
6305
- {
6306
- type: 'column_ref',
6307
- table: null,
6308
- column: {
6309
- expr: {
6310
- type: 'default',
6311
- value: 'day',
6312
- },
6313
- },
6314
- },
6315
- {
6316
- type: 'number',
6317
- value: -180,
6318
- },
6319
- {
6320
- type: 'function',
6321
- name: {
6322
- name: [
6323
- {
6324
- type: 'origin',
6325
- value: 'CURRENT_DATE',
6326
- },
6327
- ],
6355
+ args: {
6356
+ type: 'expr_list',
6357
+ value: [
6358
+ {
6359
+ type: 'single_quote_string',
6360
+ value: 'month',
6361
+ },
6362
+ {
6363
+ type: 'column_ref',
6364
+ table: null,
6365
+ column: {
6366
+ expr: {
6367
+ type: 'default',
6368
+ value: 'transaction_date',
6328
6369
  },
6329
- over: null,
6330
6370
  },
6331
- ],
6332
- },
6371
+ },
6372
+ ],
6333
6373
  },
6334
6374
  },
6335
6375
  right: {
6336
- type: 'binary_expr',
6337
- operator: '<',
6338
- left: {
6339
- type: 'column_ref',
6340
- table: null,
6341
- column: {
6342
- expr: {
6376
+ type: 'function',
6377
+ name: {
6378
+ name: [
6379
+ {
6343
6380
  type: 'default',
6344
- value: 'transaction_date',
6381
+ value: 'DATE_TRUNC',
6345
6382
  },
6346
- },
6383
+ ],
6347
6384
  },
6348
- right: {
6349
- type: 'function',
6350
- name: {
6351
- name: [
6352
- {
6353
- type: 'default',
6354
- value: 'DATEADD',
6355
- },
6356
- ],
6357
- },
6358
- args: {
6359
- type: 'expr_list',
6360
- value: [
6361
- {
6362
- type: 'column_ref',
6363
- table: null,
6364
- column: {
6365
- expr: {
6366
- type: 'default',
6385
+ args: {
6386
+ type: 'expr_list',
6387
+ value: [
6388
+ {
6389
+ type: 'single_quote_string',
6390
+ value: 'month',
6391
+ },
6392
+ {
6393
+ type: 'function',
6394
+ name: {
6395
+ name: [
6396
+ {
6397
+ type: 'origin',
6398
+ value: 'CURRENT_DATE',
6399
+ },
6400
+ ],
6401
+ },
6402
+ over: null,
6403
+ },
6404
+ ],
6405
+ },
6406
+ },
6407
+ },
6408
+ groupby: null,
6409
+ having: null,
6410
+ orderby: null,
6411
+ limit: {
6412
+ seperator: '',
6413
+ value: [],
6414
+ },
6415
+ window: null,
6416
+ },
6417
+ },
6418
+ {
6419
+ query: `
6420
+ SELECT * FROM transactions
6421
+ WHERE created_at >= date_trunc('month', CURRENT_DATE)
6422
+ AND created_at < (date_trunc('month', CURRENT_DATE) + INTERVAL '1 month')
6423
+ `,
6424
+ value: function () {
6425
+ return 0;
6426
+ },
6427
+ unit: function (astWhere) {
6428
+ return astWhere.left?.right?.args?.value[0]?.value ?? null;
6429
+ },
6430
+ ast: {
6431
+ with: null,
6432
+ type: 'select',
6433
+ options: null,
6434
+ distinct: {
6435
+ type: null,
6436
+ },
6437
+ columns: [
6438
+ {
6439
+ expr: {
6440
+ type: 'column_ref',
6441
+ table: null,
6442
+ column: '*',
6443
+ },
6444
+ as: null,
6445
+ },
6446
+ ],
6447
+ into: {
6448
+ position: null,
6449
+ },
6450
+ from: [
6451
+ {
6452
+ db: null,
6453
+ table: 'transactions',
6454
+ as: null,
6455
+ },
6456
+ ],
6457
+ where: {
6458
+ type: 'binary_expr',
6459
+ operator: 'AND',
6460
+ left: {
6461
+ type: 'binary_expr',
6462
+ operator: '>=',
6463
+ left: {
6464
+ type: 'column_ref',
6465
+ table: null,
6466
+ column: {
6467
+ expr: {
6468
+ type: 'default',
6469
+ value: 'created_at',
6470
+ },
6471
+ },
6472
+ },
6473
+ right: {
6474
+ type: 'function',
6475
+ name: {
6476
+ name: [
6477
+ {
6478
+ type: 'default',
6479
+ value: 'date_trunc',
6480
+ },
6481
+ ],
6482
+ },
6483
+ args: {
6484
+ type: 'expr_list',
6485
+ value: [
6486
+ {
6487
+ type: 'single_quote_string',
6488
+ value: 'month',
6489
+ },
6490
+ {
6491
+ type: 'function',
6492
+ name: {
6493
+ name: [
6494
+ {
6495
+ type: 'origin',
6496
+ value: 'CURRENT_DATE',
6497
+ },
6498
+ ],
6499
+ },
6500
+ over: null,
6501
+ },
6502
+ ],
6503
+ },
6504
+ },
6505
+ },
6506
+ right: {
6507
+ type: 'binary_expr',
6508
+ operator: '<',
6509
+ left: {
6510
+ type: 'column_ref',
6511
+ table: null,
6512
+ column: {
6513
+ expr: {
6514
+ type: 'default',
6515
+ value: 'created_at',
6516
+ },
6517
+ },
6518
+ },
6519
+ right: {
6520
+ type: 'binary_expr',
6521
+ operator: '+',
6522
+ left: {
6523
+ type: 'function',
6524
+ name: {
6525
+ name: [
6526
+ {
6527
+ type: 'default',
6528
+ value: 'date_trunc',
6529
+ },
6530
+ ],
6531
+ },
6532
+ args: {
6533
+ type: 'expr_list',
6534
+ value: [
6535
+ {
6536
+ type: 'single_quote_string',
6537
+ value: 'month',
6538
+ },
6539
+ {
6540
+ type: 'function',
6541
+ name: {
6542
+ name: [
6543
+ {
6544
+ type: 'origin',
6545
+ value: 'CURRENT_DATE',
6546
+ },
6547
+ ],
6548
+ },
6549
+ over: null,
6550
+ },
6551
+ ],
6552
+ },
6553
+ },
6554
+ right: {
6555
+ type: 'interval',
6556
+ expr: {
6557
+ type: 'single_quote_string',
6558
+ value: '1 month',
6559
+ },
6560
+ unit: '',
6561
+ },
6562
+ parentheses: true,
6563
+ },
6564
+ },
6565
+ },
6566
+ groupby: null,
6567
+ having: null,
6568
+ orderby: null,
6569
+ limit: {
6570
+ seperator: '',
6571
+ value: [],
6572
+ },
6573
+ window: null,
6574
+ },
6575
+ },
6576
+ ],
6577
+ },
6578
+ },
6579
+ {
6580
+ operator: Filter_1.DateOperator.InThePrevious,
6581
+ patterns: {
6582
+ redshift: [
6583
+ {
6584
+ query: `
6585
+ SELECT * FROM transactions
6586
+ WHERE transaction_date >= DATEADD(day, -180, CURRENT_DATE)
6587
+ AND transaction_date < DATEADD(day, -90, CURRENT_DATE)
6588
+ `,
6589
+ value: function (astWhere) {
6590
+ if (astWhere.right.operator === 'AND') {
6591
+ // Avoid AND chains
6592
+ return -1;
6593
+ }
6594
+ const operatorLeft = astWhere.left.operator;
6595
+ const operatorRight = astWhere.right.operator;
6596
+ const valueLeft = -astWhere.left.right?.args?.value[1]?.value;
6597
+ const valueRight = -astWhere.right.right?.args?.value[1]?.value;
6598
+ if (!valueLeft || !valueRight) {
6599
+ return null;
6600
+ }
6601
+ if (operatorLeft === '>=' &&
6602
+ operatorRight === '<' &&
6603
+ valueLeft == valueRight * 2) {
6604
+ return valueRight;
6605
+ }
6606
+ else if (operatorLeft === '<' &&
6607
+ operatorRight === '>=' &&
6608
+ valueLeft * 2 == valueRight) {
6609
+ return valueLeft;
6610
+ }
6611
+ else {
6612
+ const unitLeft = astWhere.left?.right?.args?.value[0]?.column?.expr?.value ??
6613
+ null;
6614
+ const unitRight = astWhere.right?.right?.args?.value[0]?.column?.expr?.value ??
6615
+ null;
6616
+ return parseStartEndDate(operatorLeft, operatorRight, valueLeft, valueRight, stripTimeS(unitLeft.toLowerCase()), stripTimeS(unitRight.toLowerCase()));
6617
+ }
6618
+ },
6619
+ unit: function (astWhere) {
6620
+ const unitLeft = astWhere.left?.right?.args?.value[0]?.column?.expr?.value ?? null;
6621
+ const unitRight = astWhere.right?.right?.args?.value[0]?.column?.expr?.value ??
6622
+ null;
6623
+ return stripTimeS(unitLeft.toLowerCase()) ===
6624
+ stripTimeS(unitRight.toLowerCase())
6625
+ ? stripTimeS(unitLeft.toLowerCase())
6626
+ : null;
6627
+ },
6628
+ ast: {
6629
+ with: null,
6630
+ type: 'select',
6631
+ options: null,
6632
+ distinct: {
6633
+ type: null,
6634
+ },
6635
+ columns: [
6636
+ {
6637
+ expr: {
6638
+ type: 'column_ref',
6639
+ table: null,
6640
+ column: '*',
6641
+ },
6642
+ as: null,
6643
+ },
6644
+ ],
6645
+ into: {
6646
+ position: null,
6647
+ },
6648
+ from: [
6649
+ {
6650
+ db: null,
6651
+ table: 'transactions',
6652
+ as: null,
6653
+ },
6654
+ ],
6655
+ where: {
6656
+ type: 'binary_expr',
6657
+ operator: 'AND',
6658
+ left: {
6659
+ type: 'binary_expr',
6660
+ operator: '>=',
6661
+ left: {
6662
+ type: 'column_ref',
6663
+ table: null,
6664
+ column: {
6665
+ expr: {
6666
+ type: 'default',
6667
+ value: 'transaction_date',
6668
+ },
6669
+ },
6670
+ },
6671
+ right: {
6672
+ type: 'function',
6673
+ name: {
6674
+ name: [
6675
+ {
6676
+ type: 'default',
6677
+ value: 'DATEADD',
6678
+ },
6679
+ ],
6680
+ },
6681
+ args: {
6682
+ type: 'expr_list',
6683
+ value: [
6684
+ {
6685
+ type: 'column_ref',
6686
+ table: null,
6687
+ column: {
6688
+ expr: {
6689
+ type: 'default',
6690
+ value: 'day',
6691
+ },
6692
+ },
6693
+ },
6694
+ {
6695
+ type: 'number',
6696
+ value: -180,
6697
+ },
6698
+ {
6699
+ type: 'function',
6700
+ name: {
6701
+ name: [
6702
+ {
6703
+ type: 'origin',
6704
+ value: 'CURRENT_DATE',
6705
+ },
6706
+ ],
6707
+ },
6708
+ over: null,
6709
+ },
6710
+ ],
6711
+ },
6712
+ },
6713
+ },
6714
+ right: {
6715
+ type: 'binary_expr',
6716
+ operator: '<',
6717
+ left: {
6718
+ type: 'column_ref',
6719
+ table: null,
6720
+ column: {
6721
+ expr: {
6722
+ type: 'default',
6723
+ value: 'transaction_date',
6724
+ },
6725
+ },
6726
+ },
6727
+ right: {
6728
+ type: 'function',
6729
+ name: {
6730
+ name: [
6731
+ {
6732
+ type: 'default',
6733
+ value: 'DATEADD',
6734
+ },
6735
+ ],
6736
+ },
6737
+ args: {
6738
+ type: 'expr_list',
6739
+ value: [
6740
+ {
6741
+ type: 'column_ref',
6742
+ table: null,
6743
+ column: {
6744
+ expr: {
6745
+ type: 'default',
6367
6746
  value: 'day',
6368
6747
  },
6369
6748
  },
@@ -8262,6 +8641,181 @@ const queryPatterns = [
8262
8641
  },
8263
8642
  },
8264
8643
  ],
8644
+ // TODO: Add databricks
8645
+ // using postgresql cases for now
8646
+ databricks: [
8647
+ {
8648
+ query: `
8649
+ SELECT * FROM transactions
8650
+ WHERE transaction_date >= CURRENT_DATE - INTERVAL '2 month'
8651
+ AND transaction_date < CURRENT_DATE - INTERVAL '1 month'
8652
+ `,
8653
+ value: function (astWhere) {
8654
+ if (astWhere.right.operator === 'AND') {
8655
+ // Avoid AND chains
8656
+ return -1;
8657
+ }
8658
+ const operatorLeft = astWhere.left.operator;
8659
+ const operatorRight = astWhere.right.operator;
8660
+ const valueLeft = astWhere.left.right?.right?.expr?.type === 'number'
8661
+ ? astWhere.left.right?.right?.expr?.value
8662
+ : Number(astWhere.left.right?.right?.expr?.value?.split(' ')[0]);
8663
+ const valueRight = astWhere.right.right?.right?.expr?.type === 'number'
8664
+ ? astWhere.right.right?.right?.expr?.value
8665
+ : Number(astWhere.right.right?.right?.expr?.value?.split(' ')[0]);
8666
+ if (!valueLeft || !valueRight) {
8667
+ return null;
8668
+ }
8669
+ if (operatorLeft === '>=' &&
8670
+ operatorRight === '<' &&
8671
+ valueLeft == valueRight * 2) {
8672
+ return valueRight;
8673
+ }
8674
+ else if (operatorLeft === '<' &&
8675
+ operatorRight === '>=' &&
8676
+ valueLeft * 2 == valueRight) {
8677
+ return valueLeft;
8678
+ }
8679
+ else {
8680
+ const unitLeft = astWhere.left?.right?.right?.unit === ''
8681
+ ? stripTimeS(astWhere.left.right?.right?.expr?.value?.split(' ')[1])
8682
+ : stripTimeS(astWhere.left?.right?.right?.unit);
8683
+ const unitRight = astWhere.right?.right?.right?.unit === ''
8684
+ ? stripTimeS(astWhere.right.right?.right?.expr?.value?.split(' ')[1])
8685
+ : stripTimeS(astWhere.right?.right?.right?.unit);
8686
+ return parseStartEndDate(operatorLeft, operatorRight, valueLeft, valueRight, stripTimeS(unitLeft.toLowerCase()), stripTimeS(unitRight.toLowerCase()));
8687
+ }
8688
+ },
8689
+ unit: function (astWhere) {
8690
+ const unitLeft = astWhere.left?.right?.right?.unit === ''
8691
+ ? stripTimeS(astWhere.left.right?.right?.expr?.value?.split(' ')[1])
8692
+ : stripTimeS(astWhere.left?.right?.right?.unit);
8693
+ const unitRight = astWhere.right?.right?.right?.unit === ''
8694
+ ? stripTimeS(astWhere.right.right?.right?.expr?.value?.split(' ')[1])
8695
+ : stripTimeS(astWhere.right?.right?.right?.unit);
8696
+ return stripTimeS(unitLeft.toLowerCase()) ===
8697
+ stripTimeS(unitRight.toLowerCase())
8698
+ ? stripTimeS(unitLeft.toLowerCase())
8699
+ : null;
8700
+ },
8701
+ ast: {
8702
+ with: null,
8703
+ type: 'select',
8704
+ options: null,
8705
+ distinct: {
8706
+ type: null,
8707
+ },
8708
+ columns: [
8709
+ {
8710
+ expr: {
8711
+ type: 'column_ref',
8712
+ table: null,
8713
+ column: '*',
8714
+ },
8715
+ as: null,
8716
+ },
8717
+ ],
8718
+ into: {
8719
+ position: null,
8720
+ },
8721
+ from: [
8722
+ {
8723
+ db: null,
8724
+ table: 'transactions',
8725
+ as: null,
8726
+ },
8727
+ ],
8728
+ where: {
8729
+ type: 'binary_expr',
8730
+ operator: 'AND',
8731
+ left: {
8732
+ type: 'binary_expr',
8733
+ operator: '>=',
8734
+ left: {
8735
+ type: 'column_ref',
8736
+ table: null,
8737
+ column: {
8738
+ expr: {
8739
+ type: 'default',
8740
+ value: 'transaction_date',
8741
+ },
8742
+ },
8743
+ },
8744
+ right: {
8745
+ type: 'binary_expr',
8746
+ operator: '-',
8747
+ left: {
8748
+ type: 'function',
8749
+ name: {
8750
+ name: [
8751
+ {
8752
+ type: 'origin',
8753
+ value: 'CURRENT_DATE',
8754
+ },
8755
+ ],
8756
+ },
8757
+ over: null,
8758
+ },
8759
+ right: {
8760
+ type: 'interval',
8761
+ expr: {
8762
+ type: 'single_quote_string',
8763
+ value: '2 month',
8764
+ },
8765
+ unit: '',
8766
+ },
8767
+ },
8768
+ },
8769
+ right: {
8770
+ type: 'binary_expr',
8771
+ operator: '<',
8772
+ left: {
8773
+ type: 'column_ref',
8774
+ table: null,
8775
+ column: {
8776
+ expr: {
8777
+ type: 'default',
8778
+ value: 'transaction_date',
8779
+ },
8780
+ },
8781
+ },
8782
+ right: {
8783
+ type: 'binary_expr',
8784
+ operator: '-',
8785
+ left: {
8786
+ type: 'function',
8787
+ name: {
8788
+ name: [
8789
+ {
8790
+ type: 'origin',
8791
+ value: 'CURRENT_DATE',
8792
+ },
8793
+ ],
8794
+ },
8795
+ over: null,
8796
+ },
8797
+ right: {
8798
+ type: 'interval',
8799
+ expr: {
8800
+ type: 'single_quote_string',
8801
+ value: '1 month',
8802
+ },
8803
+ unit: '',
8804
+ },
8805
+ },
8806
+ },
8807
+ },
8808
+ groupby: null,
8809
+ having: null,
8810
+ orderby: null,
8811
+ limit: {
8812
+ seperator: '',
8813
+ value: [],
8814
+ },
8815
+ window: null,
8816
+ },
8817
+ },
8818
+ ],
8265
8819
  },
8266
8820
  },
8267
8821
  ];
@@ -8498,6 +9052,7 @@ function fieldColumnToLowerCaseAst(field, db, isColumnRef, table) {
8498
9052
  };
8499
9053
  case 'postgresql':
8500
9054
  case 'clickhouse':
9055
+ case 'databricks':
8501
9056
  default:
8502
9057
  return {
8503
9058
  type: 'function',
@@ -8556,6 +9111,7 @@ function lowerFunctionToField(lower, db) {
8556
9111
  case 'mysql':
8557
9112
  case 'postgresql':
8558
9113
  case 'clickhouse':
9114
+ case 'databricks':
8559
9115
  case 'mssql':
8560
9116
  return getFieldFromExpression(lower, db) ?? '';
8561
9117
  default:
@@ -9364,6 +9920,7 @@ const filterToAst = (filter, db) => {
9364
9920
  },
9365
9921
  };
9366
9922
  case 'postgresql':
9923
+ case 'databricks': // TODO: check
9367
9924
  return {
9368
9925
  type: 'binary_expr',
9369
9926
  operator: '>=',
@@ -9982,6 +10539,7 @@ const filterToAst = (filter, db) => {
9982
10539
  };
9983
10540
  }
9984
10541
  case 'postgresql':
10542
+ case 'databricks': // TODO: check
9985
10543
  return {
9986
10544
  type: 'binary_expr',
9987
10545
  operator: '=',
@@ -10707,6 +11265,7 @@ const filterToAst = (filter, db) => {
10707
11265
  parentheses: true,
10708
11266
  };
10709
11267
  case 'postgresql':
11268
+ case 'databricks': // TODO: check
10710
11269
  return {
10711
11270
  type: 'binary_expr',
10712
11271
  operator: 'AND',