Search code examples
u-sql

Splitting Columns in USQL


I am new to USQL and I am having a hard time splitting a column from the rest of my file. With my EXTRACTOR I declared 4 columns because my file is split into 4 pipes. However, I want to remove one of the columns I declared from the file. How do I do this?

The Json column of my file is what I want to split off and make you new object that does not include it. Basically splitting Date, Status, PriceNotification into the @result. This is what I have so far:

@input =
  EXTRACT
     Date string,
     Condition string,
     Price string,
     Json string
  FROM @in
  USING Extractor.Cvs;

@result = 
  SELECT Json
  FROM @input

OUTPUT @input
TO @out
USING Outputters.Cvs();

Solution

  • Maybe I have misunderstood your question, but you can simply list the columns you want in the SELECT statement, eg

    @input =
      EXTRACT
         Date string,
         Status string,
         PriceNotification string,
         Json string
      FROM @in
      USING Extractor.Text('|');
    
    @result = 
      SELECT Date, Status, PriceNotification         
      FROM @input;
    
    OUTPUT @result
    TO @out
    USING Outputters.Cvs();
    

    NB I have switched the variable in your OUTPUT statement to be @result. If this does not answer your question, please post some sample data and expected results.