You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: datafusion/sqllogictest/test_files/string_view.slt
+364Lines changed: 364 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -322,6 +322,370 @@ logical_plan
322
322
03)----TableScan: test projection=[column1_utf8, column2_utf8, column1_utf8view]
323
323
324
324
325
+
# Ensure string functions use native StringView implementation
326
+
# and do not fall back to Utf8 or LargeUtf8
327
+
# Should see no casts to Utf8 in the plans below
328
+
329
+
## Ensure no casts for LIKE/ILIKE
330
+
query TT
331
+
EXPLAIN SELECT
332
+
column1_utf8view like 'foo' as "like",
333
+
column1_utf8view ilike 'foo' as "ilike"
334
+
FROM test;
335
+
----
336
+
logical_plan
337
+
01)Projection: test.column1_utf8view LIKE Utf8View("foo") AS like, test.column1_utf8view ILIKE Utf8View("foo") AS ilike
338
+
02)--TableScan: test projection=[column1_utf8view]
339
+
340
+
341
+
342
+
## Ensure no casts for ASCII
343
+
## TODO file ticket
344
+
query TT
345
+
EXPLAIN SELECT
346
+
ASCII(column1_utf8view) AS l
347
+
FROM test;
348
+
----
349
+
logical_plan
350
+
01)Projection: ascii(CAST(test.column1_utf8view AS Utf8)) AS l
351
+
02)--TableScan: test projection=[column1_utf8view]
352
+
353
+
354
+
## Ensure no casts for BTRIM
355
+
## TODO file ticket
356
+
query TT
357
+
EXPLAIN SELECT
358
+
BTRIM(column1_utf8view, 'foo') AS l
359
+
FROM test;
360
+
----
361
+
logical_plan
362
+
01)Projection: btrim(CAST(test.column1_utf8view AS Utf8), Utf8("foo")) AS l
363
+
02)--TableScan: test projection=[column1_utf8view]
364
+
365
+
## Ensure no casts for CHARACTER_LENGTH
366
+
## TODO file ticket
367
+
query TT
368
+
EXPLAIN SELECT
369
+
CHARACTER_LENGTH(column1_utf8view) AS l
370
+
FROM test;
371
+
----
372
+
logical_plan
373
+
01)Projection: character_length(CAST(test.column1_utf8view AS Utf8)) AS l
374
+
02)--TableScan: test projection=[column1_utf8view]
375
+
376
+
## Ensure no casts for CONCAT
377
+
## TODO file ticket
378
+
query TT
379
+
EXPLAIN SELECT
380
+
concat(column1_utf8view, column2_utf8view) as c
381
+
FROM test;
382
+
----
383
+
logical_plan
384
+
01)Projection: concat(CAST(test.column1_utf8view AS Utf8), CAST(test.column2_utf8view AS Utf8)) AS c
385
+
02)--TableScan: test projection=[column1_utf8view, column2_utf8view]
386
+
387
+
## Ensure no casts for CONCAT_WS
388
+
## TODO file ticket
389
+
query TT
390
+
EXPLAIN SELECT
391
+
concat_ws(', ', column1_utf8view, column2_utf8view) as c
392
+
FROM test;
393
+
----
394
+
logical_plan
395
+
01)Projection: concat_ws(Utf8(", "), CAST(test.column1_utf8view AS Utf8), CAST(test.column2_utf8view AS Utf8)) AS c
396
+
02)--TableScan: test projection=[column1_utf8view, column2_utf8view]
397
+
398
+
## Ensure no casts for CONTAINS
399
+
## TODO file ticket
400
+
query TT
401
+
EXPLAIN SELECT
402
+
CONTAINS(column1_utf8view, 'foo') as c1,
403
+
CONTAINS(column2_utf8view, column2_utf8view) as c2
404
+
FROM test;
405
+
----
406
+
logical_plan
407
+
01)Projection: contains(CAST(test.column1_utf8view AS Utf8), Utf8("foo")) AS c1, contains(__common_expr_1, __common_expr_1) AS c2
408
+
02)--Projection: CAST(test.column2_utf8view AS Utf8) AS __common_expr_1, test.column1_utf8view
409
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
410
+
411
+
## Ensure no casts for ENDS_WITH
412
+
## TODO file ticket
413
+
query TT
414
+
EXPLAIN SELECT
415
+
ENDS_WITH(column1_utf8view, 'foo') as c1,
416
+
ENDS_WITH(column2_utf8view, column2_utf8view) as c2
417
+
FROM test;
418
+
----
419
+
logical_plan
420
+
01)Projection: ends_with(CAST(test.column1_utf8view AS Utf8), Utf8("foo")) AS c1, ends_with(__common_expr_1, __common_expr_1) AS c2
421
+
02)--Projection: CAST(test.column2_utf8view AS Utf8) AS __common_expr_1, test.column1_utf8view
422
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
423
+
424
+
425
+
## Ensure no casts for INITCAP
426
+
## TODO file ticket
427
+
query TT
428
+
EXPLAIN SELECT
429
+
INITCAP(column1_utf8view) as c
430
+
FROM test;
431
+
----
432
+
logical_plan
433
+
01)Projection: initcap(CAST(test.column1_utf8view AS Utf8)) AS c
434
+
02)--TableScan: test projection=[column1_utf8view]
435
+
436
+
## Ensure no casts for LEVENSHTEIN
437
+
## TODO file ticket
438
+
query TT
439
+
EXPLAIN SELECT
440
+
levenshtein(column1_utf8view, 'foo') as c1,
441
+
levenshtein(column1_utf8view, column2_utf8view) as c2
442
+
FROM test;
443
+
----
444
+
logical_plan
445
+
01)Projection: levenshtein(__common_expr_1, Utf8("foo")) AS c1, levenshtein(__common_expr_1, CAST(test.column2_utf8view AS Utf8)) AS c2
446
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1, test.column2_utf8view
447
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
448
+
449
+
## Ensure no casts for LOWER
450
+
## TODO file ticket
451
+
query TT
452
+
EXPLAIN SELECT
453
+
LOWER(column1_utf8view) as c1
454
+
FROM test;
455
+
----
456
+
logical_plan
457
+
01)Projection: lower(CAST(test.column1_utf8view AS Utf8)) AS c1
458
+
02)--TableScan: test projection=[column1_utf8view]
459
+
460
+
## Ensure no casts for LTRIM
461
+
## TODO file ticket
462
+
query TT
463
+
EXPLAIN SELECT
464
+
LTRIM(column1_utf8view) as c1
465
+
FROM test;
466
+
----
467
+
logical_plan
468
+
01)Projection: ltrim(CAST(test.column1_utf8view AS Utf8)) AS c1
469
+
02)--TableScan: test projection=[column1_utf8view]
470
+
471
+
## Ensure no casts for LPAD
472
+
## TODO file ticket
473
+
query TT
474
+
EXPLAIN SELECT
475
+
LPAD(column1_utf8view, 12, ' ') as c1
476
+
FROM test;
477
+
----
478
+
logical_plan
479
+
01)Projection: lpad(CAST(test.column1_utf8view AS Utf8), Int64(12), Utf8(" ")) AS c1
480
+
02)--TableScan: test projection=[column1_utf8view]
481
+
482
+
483
+
## Ensure no casts for OCTET_LENGTH
484
+
## TODO file ticket
485
+
query TT
486
+
EXPLAIN SELECT
487
+
OCTET_LENGTH(column1_utf8view) as c1
488
+
FROM test;
489
+
----
490
+
logical_plan
491
+
01)Projection: octet_length(CAST(test.column1_utf8view AS Utf8)) AS c1
492
+
02)--TableScan: test projection=[column1_utf8view]
493
+
494
+
## Ensure no casts for OVERLAY
495
+
## TODO file ticket
496
+
query TT
497
+
EXPLAIN SELECT
498
+
OVERLAY(column1_utf8view PLACING 'foo' FROM 2 ) as c1
499
+
FROM test;
500
+
----
501
+
logical_plan
502
+
01)Projection: overlay(CAST(test.column1_utf8view AS Utf8), Utf8("foo"), Int64(2)) AS c1
503
+
02)--TableScan: test projection=[column1_utf8view]
504
+
505
+
## Ensure no casts for REGEXP_LIKE
506
+
query error DataFusion error: Error during planning: The regexp_like function can only accept strings\. Got Utf8View
507
+
EXPLAIN SELECT
508
+
REGEXP_LIKE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k
509
+
FROM test;
510
+
511
+
## Ensure no casts for REGEXP_MATCH
512
+
query error DataFusion error: Error during planning: The regexp_match function can only accept strings\. Got Utf8View
513
+
EXPLAIN SELECT
514
+
REGEXP_MATCH(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k
515
+
FROM test;
516
+
517
+
## Ensure no casts for REGEXP_REPLACE
518
+
query TT
519
+
EXPLAIN SELECT
520
+
REGEXP_REPLACE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k
521
+
FROM test;
522
+
----
523
+
logical_plan
524
+
01)Projection: regexp_replace(test.column1_utf8view, Utf8("^https?://(?:www\.)?([^/]+)/.*$"), Utf8("\1")) AS k
525
+
02)--TableScan: test projection=[column1_utf8view]
526
+
527
+
528
+
## Ensure no casts for REPEAT
529
+
## TODO file ticket
530
+
query TT
531
+
EXPLAIN SELECT
532
+
REPEAT(column1_utf8view, 2) as c1
533
+
FROM test;
534
+
----
535
+
logical_plan
536
+
01)Projection: repeat(CAST(test.column1_utf8view AS Utf8), Int64(2)) AS c1
537
+
02)--TableScan: test projection=[column1_utf8view]
538
+
539
+
## Ensure no casts for REPLACE
540
+
## TODO file ticket
541
+
query TT
542
+
EXPLAIN SELECT
543
+
REPLACE(column1_utf8view, 'foo', 'bar') as c1,
544
+
REPLACE(column1_utf8view, column2_utf8view, 'bar') as c2
545
+
FROM test;
546
+
----
547
+
logical_plan
548
+
01)Projection: replace(__common_expr_1, Utf8("foo"), Utf8("bar")) AS c1, replace(__common_expr_1, CAST(test.column2_utf8view AS Utf8), Utf8("bar")) AS c2
549
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1, test.column2_utf8view
550
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
551
+
552
+
## Ensure no casts for REVERSE
553
+
## TODO file ticket
554
+
query TT
555
+
EXPLAIN SELECT
556
+
REVERSE(column1_utf8view) as c1
557
+
FROM test;
558
+
----
559
+
logical_plan
560
+
01)Projection: reverse(CAST(test.column1_utf8view AS Utf8)) AS c1
561
+
02)--TableScan: test projection=[column1_utf8view]
562
+
563
+
## Ensure no casts for RTRIM
564
+
## TODO file ticket
565
+
query TT
566
+
EXPLAIN SELECT
567
+
RTRIM(column1_utf8view) as c1,
568
+
RTRIM(column1_utf8view, 'foo') as c2
569
+
FROM test;
570
+
----
571
+
logical_plan
572
+
01)Projection: rtrim(__common_expr_1) AS c1, rtrim(__common_expr_1, Utf8("foo")) AS c2
573
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1
574
+
03)----TableScan: test projection=[column1_utf8view]
575
+
576
+
## Ensure no casts for RIGHT
577
+
## TODO file ticket
578
+
query TT
579
+
EXPLAIN SELECT
580
+
RIGHT(column1_utf8view, 3) as c2
581
+
FROM test;
582
+
----
583
+
logical_plan
584
+
01)Projection: right(CAST(test.column1_utf8view AS Utf8), Int64(3)) AS c2
585
+
02)--TableScan: test projection=[column1_utf8view]
586
+
587
+
## Ensure no casts for RPAD
588
+
## TODO file ticket
589
+
query TT
590
+
EXPLAIN SELECT
591
+
RPAD(column1_utf8view, 1) as c1,
592
+
RPAD(column1_utf8view, 2, column2_utf8view) as c2
593
+
FROM test;
594
+
----
595
+
logical_plan
596
+
01)Projection: rpad(__common_expr_1, Int64(1)) AS c1, rpad(__common_expr_1, Int64(2), CAST(test.column2_utf8view AS Utf8)) AS c2
597
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1, test.column2_utf8view
598
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
599
+
600
+
601
+
## Ensure no casts for RTRIM
602
+
## TODO file ticket
603
+
query TT
604
+
EXPLAIN SELECT
605
+
RTRIM(column1_utf8view) as c,
606
+
RTRIM(column1_utf8view, column2_utf8view) as c1
607
+
FROM test;
608
+
----
609
+
logical_plan
610
+
01)Projection: rtrim(__common_expr_1) AS c, rtrim(__common_expr_1, CAST(test.column2_utf8view AS Utf8)) AS c1
611
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1, test.column2_utf8view
612
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
613
+
614
+
## Ensure no casts for SPLIT_PART
615
+
## TODO file ticket
616
+
query TT
617
+
EXPLAIN SELECT
618
+
SPLIT_PART(column1_utf8view, 'f', 1) as c
619
+
FROM test;
620
+
----
621
+
logical_plan
622
+
01)Projection: split_part(CAST(test.column1_utf8view AS Utf8), Utf8("f"), Int64(1)) AS c
623
+
02)--TableScan: test projection=[column1_utf8view]
624
+
625
+
## Ensure no casts for STRPOS
626
+
## TODO file ticket
627
+
query TT
628
+
EXPLAIN SELECT
629
+
STRPOS(column1_utf8view, 'f') as c,
630
+
STRPOS(column1_utf8view, column2_utf8view) as c2
631
+
FROM test;
632
+
----
633
+
logical_plan
634
+
01)Projection: strpos(__common_expr_1, Utf8("f")) AS c, strpos(__common_expr_1, CAST(test.column2_utf8view AS Utf8)) AS c2
635
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1, test.column2_utf8view
636
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
637
+
638
+
## Ensure no casts for SUBSTR
639
+
## TODO file ticket
640
+
query TT
641
+
EXPLAIN SELECT
642
+
SUBSTR(column1_utf8view, 1) as c,
643
+
SUBSTR(column1_utf8view, 1 ,2) as c2
644
+
FROM test;
645
+
----
646
+
logical_plan
647
+
01)Projection: substr(__common_expr_1, Int64(1)) AS c, substr(__common_expr_1, Int64(1), Int64(2)) AS c2
648
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1
649
+
03)----TableScan: test projection=[column1_utf8view]
650
+
651
+
## Ensure no casts for STARTS_WITH
652
+
## TODO file ticket
653
+
query TT
654
+
EXPLAIN SELECT
655
+
STARTS_WITH(column1_utf8view, 'foo') as c,
656
+
STARTS_WITH(column1_utf8view, column2_utf8view) as c2
657
+
FROM test;
658
+
----
659
+
logical_plan
660
+
01)Projection: starts_with(__common_expr_1, Utf8("foo")) AS c, starts_with(__common_expr_1, CAST(test.column2_utf8view AS Utf8)) AS c2
661
+
02)--Projection: CAST(test.column1_utf8view AS Utf8) AS __common_expr_1, test.column2_utf8view
662
+
03)----TableScan: test projection=[column1_utf8view, column2_utf8view]
663
+
664
+
## Ensure no casts for TRANSLATE
665
+
## TODO file ticket
666
+
query TT
667
+
EXPLAIN SELECT
668
+
TRANSLATE(column1_utf8view, 'foo', 'bar') as c
669
+
FROM test;
670
+
----
671
+
logical_plan
672
+
01)Projection: translate(CAST(test.column1_utf8view AS Utf8), Utf8("foo"), Utf8("bar")) AS c
673
+
02)--TableScan: test projection=[column1_utf8view]
674
+
675
+
## Ensure no casts for FIND_IN_SET
676
+
## TODO file ticket
677
+
query TT
678
+
EXPLAIN SELECT
679
+
FIND_IN_SET(column1_utf8view, 'a,b,c,d') as c
680
+
FROM test;
681
+
----
682
+
logical_plan
683
+
01)Projection: find_in_set(CAST(test.column1_utf8view AS Utf8), Utf8("a,b,c,d")) AS c
684
+
02)--TableScan: test projection=[column1_utf8view]
0 commit comments