Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-18952

regex strings not properly escaped in codegen for aggregations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.2
    • 2.1.1, 2.2.0
    • SQL
    • None

    Description

      If I use the function regexp_extract, and then in my regex string, use `\`, i.e. escape character, this fails codegen, because the `\` character is not properly escaped when codegen'd.

      Example stack trace:

      /* 059 */     private int maxSteps = 2;
      /* 060 */     private int numRows = 0;
      /* 061 */     private org.apache.spark.sql.types.StructType keySchema = new org.apache.spark.sql.types.StructType().add("date_format(window#325.start, yyyy-MM-dd HH:mm)", org.apache.spark.sql.types.DataTypes.StringType)
      /* 062 */     .add("regexp_extract(source#310.description, ([a-zA-Z]+)\[.*, 1)", org.apache.spark.sql.types.DataTypes.StringType);
      /* 063 */     private org.apache.spark.sql.types.StructType valueSchema = new org.apache.spark.sql.types.StructType().add("sum", org.apache.spark.sql.types.DataTypes.LongType);
      /* 064 */     private Object emptyVBase;
      
      ...
      
      org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 62, Column 58: Invalid escape sequence
      	at org.codehaus.janino.Scanner.scanLiteralCharacter(Scanner.java:918)
      	at org.codehaus.janino.Scanner.produce(Scanner.java:604)
      	at org.codehaus.janino.Parser.peekRead(Parser.java:3239)
      	at org.codehaus.janino.Parser.parseArguments(Parser.java:3055)
      	at org.codehaus.janino.Parser.parseSelector(Parser.java:2914)
      	at org.codehaus.janino.Parser.parseUnaryExpression(Parser.java:2617)
      	at org.codehaus.janino.Parser.parseMultiplicativeExpression(Parser.java:2573)
      	at org.codehaus.janino.Parser.parseAdditiveExpression(Parser.java:2552)
      

      In the codegend expression, the literal should use `
      ` instead of `\`

      Attachments

        Issue Links

          Activity

            People

              brkyvz Burak Yavuz
              brkyvz Burak Yavuz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: