@@ -160,11 +160,11 @@ private static String grok(List<Column> previousOutput) {
160160            }
161161            result .append ("%{WORD:" );
162162            if  (randomBoolean ()) {
163-                 result .append (randomAlphaOfLength ( 5 ));
163+                 result .append (randomIdentifier ( ));
164164            } else  {
165165                String  fieldName  = randomRawName (previousOutput );
166166                if  (fieldName .isEmpty ()) { // it's a bug, managed later, skipping for now 
167-                     fieldName  = randomAlphaOfLength ( 5 );
167+                     fieldName  = randomIdentifier ( );
168168                }
169169                result .append (fieldName );
170170            }
@@ -188,11 +188,11 @@ private static String dissect(List<Column> previousOutput) {
188188            }
189189            result .append ("%{" );
190190            if  (randomBoolean ()) {
191-                 result .append (randomAlphaOfLength ( 5 ));
191+                 result .append (randomIdentifier ( ));
192192            } else  {
193193                String  fieldName  = randomRawName (previousOutput );
194194                if  (fieldName .isEmpty ()) { // it's a bug, managed later, skipping for now 
195-                     fieldName  = randomAlphaOfLength ( 5 );
195+                     fieldName  = randomIdentifier ( );
196196                }
197197                result .append (fieldName );
198198            }
@@ -302,7 +302,7 @@ private static String rename(List<Column> previousOutput) {
302302
303303            String  newName ;
304304            if  (names .isEmpty () || randomBoolean ()) {
305-                 newName  = randomAlphaOfLength ( 5 );
305+                 newName  = randomIdentifier ( );
306306                names .add (newName );
307307            } else  {
308308                newName  = names .get (randomIntBetween (0 , names .size () - 1 ));
@@ -376,7 +376,7 @@ private static String eval(List<Column> previousOutput) {
376376        for  (int  i  = 0 ; i  < nFields ; i ++) {
377377            String  name ;
378378            if  (randomBoolean ()) {
379-                 name  = randomAlphaOfLength ( randomIntBetween ( 3 ,  10 ) );
379+                 name  = randomIdentifier ( );
380380            } else  {
381381                name  = randomName (previousOutput );
382382            }
@@ -402,7 +402,7 @@ private static String stats(List<Column> previousOutput) {
402402        for  (int  i  = 0 ; i  < nStats ; i ++) {
403403            String  name ;
404404            if  (randomBoolean ()) {
405-                 name  = randomAlphaOfLength ( randomIntBetween ( 3 ,  10 ) );
405+                 name  = randomIdentifier ( );
406406            } else  {
407407                name  = randomName (previousOutput );
408408            }
@@ -501,7 +501,7 @@ private static String row() {
501501        StringBuilder  cmd  = new  StringBuilder ("row " );
502502        int  nFields  = randomIntBetween (1 , 10 );
503503        for  (int  i  = 0 ; i  < nFields ; i ++) {
504-             String  name  = randomAlphaOfLength ( randomIntBetween ( 3 ,  10 ) );
504+             String  name  = randomIdentifier ( );
505505            String  expression  = constantExpression ();
506506            if  (i  > 0 ) {
507507                cmd .append ("," );
@@ -526,4 +526,10 @@ private static String constantExpression() {
526526
527527    }
528528
529+     private  static  String  randomIdentifier () {
530+         // Let's create identifiers that are long enough to avoid collisions with reserved keywords. 
531+         // There could be a smarter way (introspection on the lexer class?), but probably it's not worth the effort 
532+         return  randomAlphaOfLength (randomIntBetween (8 , 12 ));
533+     }
534+ 
529535}
0 commit comments