Class CopyCommandExecutor

java.lang.Object
dev.frostlake.executor.copy.CopyCommandExecutor

public final class CopyCommandExecutor extends Object
Executes the COPY subsystem — the stage-file load (COPY INTO <table>) and unload (COPY INTO <stage>) paths, VALIDATION_MODE, COPY transformations, and the file/format dispatch — on behalf of QueryExecutor. Extracted from the executor to keep its file I/O and COPY-local state (load history, pipe-REFRESH filters) in one collaborator. The executor holds one instance and forwards its COPY entry points here; shared stage helpers (base-dir resolution, stage-ref encoding, file listing) stay on the executor and are called back through it.
  • Constructor Details

    • CopyCommandExecutor

      public CopyCommandExecutor(QueryExecutor executor)
  • Method Details

    • forgetLoadHistory

      public void forgetLoadHistory(String fullyQualifiedTableName)
      TRUNCATE and CREATE OR REPLACE / DROP of the table discard its history; DELETE never does.
    • executeCopyIntoFromContext

      public Object executeCopyIntoFromContext(FrostlakeParser.CopyIntoStatementContext ctx)
    • executeCopyRefresh

      public Object executeCopyRefresh(String copyStatement, String prefix, String modifiedAfter)
      ALTER PIPE … REFRESH: run the pipe's stored COPY, but restrict the files it loads to those whose stage-relative path starts with prefix and/or whose last-modified time is strictly after modifiedAfter (matching Snowflake's REFRESH PREFIX / MODIFIED_AFTER). Either filter may be null (absent). The filters are scoped to this single COPY and cleared afterwards.
    • parseCsvLine

      public static List<String> parseCsvLine(String line, char delimiter, Character enclosure, List<Boolean> enclosedOut)
      Split one CSV line on delimiter, honoring an optional enclosure character (with "" escaping). Public so the stage-query path (SELECT … FROM @stage) reads fields exactly the way COPY INTO does.

      enclosedOut collects, alongside each field, whether an enclosure produced it. The flag keeps an enclosed empty ("") apart from a blank field — EMPTY_FIELD_AS_NULL nulls only the blank one — and marks the fields TRIM_SPACE must leave untrimmed (see applyCsvFieldOptions(java.util.List<java.lang.String>, boolean, java.util.List<java.lang.String>, boolean, java.util.List<java.lang.Boolean>, java.util.List<java.lang.String>)). It is filled in field order and stays empty when no enclosure is configured, since neither distinction can arise then.

    • parseCsvLine

      public static List<String> parseCsvLine(String line, char delimiter, Character enclosure, List<Boolean> enclosedOut, List<String> enclosedContentOut)
      The four-argument split plus, when enclosedContentOut is given, each field's ENCLOSURE CONTENT — the characters between the first opening and last closing enclosure, escapes resolved, with whatever sat outside the enclosure left out. TRIM_SPACE needs it: the account trims spaces around the enclosure but keeps the enclosed content verbatim, so " x y " loads as x y (padding inside the quotes intact). For a field with no enclosure the content is the field itself.