@@ -533,6 +533,7 @@ function filter_columns_by_expr(actual_expr, metadata::DataFrame)
533533 # Filter metadata by current_selxn != 0
534534 selected_df = metadata[metadata. current_selxn .!= 0 , :]
535535 all_columns = selected_df. name
536+
536537 function maybe_uppercase (s)
537538 if current_sql_mode[] == snowflake ()
538539 return uppercase (s)
@@ -550,47 +551,56 @@ function filter_columns_by_expr(actual_expr, metadata::DataFrame)
550551 end
551552 end
552553
554+ # Handle everything() directly
555+ if (isa (actual_expr, Expr) && actual_expr. head == :call && actual_expr. args[1 ] == :everything ) || actual_expr == :everything
556+ local_cols = current_sql_mode[] == snowflake () ? uppercase .(all_columns) : all_columns
557+ return collect (local_cols)
558+ end
559+
553560 # If actual_expr is a vector, process each element individually
554561 if isa (actual_expr, AbstractVector)
555562 final_columns = String[]
556563 for elem in actual_expr
557564 if isa (elem, AbstractVector)
558- # elem is directly a vector of symbols like [:groups, :value]
559565 col_strs = string .(elem)
560566 local_cols = all_columns
561567 if current_sql_mode[] == snowflake ()
562568 col_strs = uppercase .(col_strs)
563569 local_cols = uppercase .(local_cols)
564570 end
565- # Check if all requested columns exist
566571 missing_cols = setdiff (col_strs, intersect (col_strs, local_cols))
567572 if ! isempty (missing_cols)
568573 error (" The following columns were not found: $(missing_cols) " )
569574 end
570575 append! (final_columns, col_strs)
576+
571577 elseif isa (elem, Symbol)
572- # elem is a single symbol, try parsing
573578 elem_str = string (elem)
574579 parsed = Meta. parse (elem_str)
580+
575581 if isa (parsed, Expr) && parsed. head == :vect
576- # It's a vector expression like [groups, value]
577582 col_syms = parsed. args
578583 col_strs = string .(col_syms)
579584 local_cols = all_columns
580585 if current_sql_mode[] == snowflake ()
581586 col_strs = uppercase .(col_strs)
582587 local_cols = uppercase .(local_cols)
583588 end
584- col_strs = replace .(col_strs, " :" => " " )
589+ col_strs = replace .(col_strs, " :" => " " )
585590 missing_cols = setdiff (col_strs, intersect (col_strs, local_cols))
586591 if ! isempty (missing_cols)
587592 error (" The following columns were not found: $(missing_cols) " )
588593 end
589594 append! (final_columns, col_strs)
595+
590596 elseif isa (parsed, Expr) && parsed. head == :call
591597 func = parsed. args[1 ]
592- if func == :(:)
593- # Handle range expression like id:groups
598+
599+ if func == :everything
600+ local_cols = current_sql_mode[] == snowflake () ? uppercase .(all_columns) : all_columns
601+ append! (final_columns, local_cols)
602+
603+ elseif func == :(:)
594604 start_col = string (parsed. args[2 ])
595605 end_col = string (parsed. args[3 ])
596606 if current_sql_mode[] == snowflake ()
@@ -605,25 +615,22 @@ function filter_columns_by_expr(actual_expr, metadata::DataFrame)
605615 end
606616 range_columns = all_columns[start_idx: end_idx]
607617 append! (final_columns, range_columns)
608- elseif isa (parsed, Expr) && parsed. head == :call
609- # It's a function call expression like ends_with("d")
610- func = parsed. args[1 ]
611- if func == :starts_with || func == :ends_with || func == :contains
612- substring = string (parsed. args[2 ])
613- substring = maybe_uppercase (substring)
614- local_cols = current_sql_mode[] == snowflake () ? uppercase .(all_columns) : all_columns
615- match_columns = filter (col ->
616- (func == :starts_with && startswith (col, substring)) ||
617- (func == :ends_with && endswith (col, substring)) ||
618- (func == :contains && occursin (substring, col)),
619- local_cols)
620- append! (final_columns, match_columns)
621- else
622- error (" Unsupported function call: $(func) " )
623- end
618+
619+ elseif func == :starts_with || func == :ends_with || func == :contains
620+ substring = string (parsed. args[2 ])
621+ substring = maybe_uppercase (substring)
622+ local_cols = current_sql_mode[] == snowflake () ? uppercase .(all_columns) : all_columns
623+ match_columns = filter (col ->
624+ (func == :starts_with && startswith (col, substring)) ||
625+ (func == :ends_with && endswith (col, substring)) ||
626+ (func == :contains && occursin (substring, col)),
627+ local_cols)
628+ append! (final_columns, match_columns)
629+
630+ else
631+ error (" Unsupported function call: $(func) " )
624632 end
625633 else
626- # Treat as a direct column reference
627634 local_cols = all_columns
628635 if current_sql_mode[] == snowflake ()
629636 elem_str = uppercase (elem_str)
@@ -636,9 +643,13 @@ function filter_columns_by_expr(actual_expr, metadata::DataFrame)
636643 error (" The following columns were not found: [$elem_str ]" )
637644 end
638645 end
646+
639647 elseif isa (elem, String)
640- # If the string starts with function call syntax, process it as a function call
641- if startswith (elem, " starts_with(" ) || startswith (elem, " ends_with(" ) || startswith (elem, " contains(" )
648+ if elem == " everything()" || elem == " everything"
649+ local_cols = current_sql_mode[] == snowflake () ? uppercase .(all_columns) : all_columns
650+ append! (final_columns, local_cols)
651+
652+ elseif startswith (elem, " starts_with(" ) || startswith (elem, " ends_with(" ) || startswith (elem, " contains(" )
642653 parsed = Meta. parse (elem)
643654 if isa (parsed, Expr) && parsed. head == :call
644655 func = parsed. args[1 ]
@@ -658,37 +669,38 @@ function filter_columns_by_expr(actual_expr, metadata::DataFrame)
658669 else
659670 error (" Invalid function expression: $elem " )
660671 end
661- elseif startswith (elem, " :" )
662- col = replace (elem, " :" => " " )
663- local_cols = all_columns
664- if current_sql_mode[] == snowflake ()
665- col = uppercase (col)
666- local_cols = uppercase .(local_cols)
667- end
668- idx = findfirst (== (col), local_cols)
669- if isnothing (idx)
670- error (" Column not found: $col " )
671- end
672- push! (final_columns, local_cols[idx])
673- elseif occursin (" :" , elem)
674- parts = split (elem, " :" )
675- start_col, end_col = parts[1 ], parts[2 ]
676- local_cols = all_columns
677- if current_sql_mode[] == snowflake ()
678- start_col = uppercase (start_col)
679- end_col = uppercase (end_col)
680- local_cols = uppercase .(local_cols)
681- end
682- start_idx = findfirst (== (start_col), local_cols)
683- end_idx = findfirst (== (end_col), local_cols)
684- if isnothing (start_idx) || isnothing (end_idx) || start_idx > end_idx
685- error (" Column range not found or invalid: $start_col to $end_col " )
686- end
687- range_columns = local_cols[start_idx: end_idx]
688- append! (final_columns, range_columns)
689-
672+
673+ elseif startswith (elem, " :" )
674+ col = replace (elem, " :" => " " )
675+ local_cols = all_columns
676+ if current_sql_mode[] == snowflake ()
677+ col = uppercase (col)
678+ local_cols = uppercase .(local_cols)
679+ end
680+ idx = findfirst (== (col), local_cols)
681+ if isnothing (idx)
682+ error (" Column not found: $col " )
683+ end
684+ push! (final_columns, local_cols[idx])
685+
686+ elseif occursin (" :" , elem)
687+ parts = split (elem, " :" )
688+ start_col, end_col = parts[1 ], parts[2 ]
689+ local_cols = all_columns
690+ if current_sql_mode[] == snowflake ()
691+ start_col = uppercase (start_col)
692+ end_col = uppercase (end_col)
693+ local_cols = uppercase .(local_cols)
694+ end
695+ start_idx = findfirst (== (start_col), local_cols)
696+ end_idx = findfirst (== (end_col), local_cols)
697+ if isnothing (start_idx) || isnothing (end_idx) || start_idx > end_idx
698+ error (" Column range not found or invalid: $start_col to $end_col " )
699+ end
700+ range_columns = local_cols[start_idx: end_idx]
701+ append! (final_columns, range_columns)
702+
690703 else
691- # Treat as a direct column reference
692704 local_cols = all_columns
693705 if current_sql_mode[] == snowflake ()
694706 elem_upper = uppercase (elem)
@@ -702,12 +714,11 @@ function filter_columns_by_expr(actual_expr, metadata::DataFrame)
702714 error (" The following column was not found: [$elem ]" )
703715 end
704716 end
705- else
706- println (final_columns)
707717 end
708718 end
709719 return final_columns
710720 end
711721end
712722
713- # COV_EXCL_STOP
723+
724+ # COV_EXCL_STOP
0 commit comments