This is an automated email from the ASF dual-hosted git repository.

yashmayya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new f6b930b4de8 Always generate the SQL parser in pinot-common's main 
build to fix intermittent clean install failures (#18623)
f6b930b4de8 is described below

commit f6b930b4de86cde50a03713dd6c611032c2929b6
Author: Yash Mayya <[email protected]>
AuthorDate: Fri May 29 09:21:02 2026 -0700

    Always generate the SQL parser in pinot-common's main build to fix 
intermittent clean install failures (#18623)
---
 pinot-common/pom.xml | 103 +++++++++++++++++++++++----------------------------
 1 file changed, 47 insertions(+), 56 deletions(-)

diff --git a/pinot-common/pom.xml b/pinot-common/pom.xml
index 87e601b2627..a6630836cba 100644
--- a/pinot-common/pom.xml
+++ b/pinot-common/pom.xml
@@ -97,7 +97,53 @@
           </java>
         </configuration>
       </plugin>
-      <!-- Creates a Java class for the custom parser from Parser.jj -->
+      <!-- Stage 1 of SQL parser codegen: FMPP plugs Pinot's custom grammar 
(config.fmpp +
+           templates/Parser.jj) into Calcite's parser template and writes the 
JavaCC grammar to
+           target/generated-sources/javacc/Parser.jj. Declared before 
javacc-maven-plugin so it runs
+           first within the generate-sources phase (same-phase goals execute 
in POM declaration order). -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-fmpp-sources</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <target name="generate-parser">
+                <taskdef name="fmpp" classname="fmpp.tools.AntTask" 
classpathref="maven.compile.classpath" />
+                <!-- FMPP unconditionally rewrites its output, so generating 
straight into the JavaCC
+                     source dir would bump Parser.jj's timestamp every build 
and force JavaCC + the
+                     entire module to recompile. Instead generate into a 
staging dir, then copy into
+                     the JavaCC source dir only when the grammar content 
actually changed (compared
+                     byte-for-byte via the 'different' selector, ignoring 
timestamps). This keeps
+                     incremental builds fast while guaranteeing the grammar is 
regenerated after a
+                     clean. It replaces the old 'sqlparser' profile, whose 
file-based activation was
+                     evaluated before 'clean' deleted the file it keyed on, 
breaking 'clean install'. -->
+                <mkdir dir="${project.build.directory}/generated-sources/fmpp" 
/>
+                <fmpp configuration="src/main/codegen/config.fmpp" 
sourceRoot="src/main/codegen/templates" 
outputRoot="${project.build.directory}/generated-sources/fmpp" />
+                <mkdir 
dir="${project.build.directory}/generated-sources/javacc" />
+                <copy 
todir="${project.build.directory}/generated-sources/javacc">
+                  <fileset 
dir="${project.build.directory}/generated-sources/fmpp/javacc">
+                    <include name="Parser.jj" />
+                    <different 
targetdir="${project.build.directory}/generated-sources/javacc" 
ignoreFileTimes="true" />
+                  </fileset>
+                </copy>
+              </target>
+            </configuration>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>net.sourceforge.fmpp</groupId>
+            <artifactId>fmpp</artifactId>
+            <version>${fmpp.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+      <!-- Stage 2 of SQL parser codegen: compile the generated Parser.jj into 
SqlParserImpl. -->
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>javacc-maven-plugin</artifactId>
@@ -384,60 +430,5 @@
         <shade.phase.prop>none</shade.phase.prop>
       </properties>
     </profile>
-    <profile>
-      <!-- The Ant task doesn't care about unchanged (re)sources and will 
always generate.
-      This causes the maven-compiler-plugin to detect changes and always 
recompile the Java sources.
-
-      If there are changes in src/main/codegen, either enforcer activation of 
this profile by using -Psqlparser or by
-      removing the generated-sources/javacc directory
-
-      NOTICE: In Maven the profile activation is decided BEFORE plugin 
execution.
-      When running clean+verify, the profile will not be activated (because 
the file still exists),
-        clean will remove it and compiler-plugin will fail because of a 
missing class.
-        Either run 'mvn clean && mvn verify' or 'mvn verify -Psqlparser'
-       -->
-      <id>sqlparser</id>
-      <activation>
-        <file>
-          
<missing>${basedir}/target/generated-sources/javacc/Parser.jj</missing>
-        </file>
-      </activation>
-      <build>
-        <plugins>
-          <!-- "Plugs in" the Calcite's Parser.jj with the variables present 
in config.fmpp. These contain the custom rules
-     as well as the class to which the custom implementation will get 
generated -->
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-antrun-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>generate-fmpp-sources</id>
-                <phase>generate-sources</phase>
-                <goals>
-                  <goal>run</goal>
-                </goals>
-                <configuration>
-                  <target name="generate-code">
-                    <taskdef name="fmpp" classname="fmpp.tools.AntTask" 
classpathref="maven.compile.classpath" />
-                    <fmpp configuration="src/main/codegen/config.fmpp" 
sourceRoot="src/main/codegen/templates" 
outputRoot="${project.build.directory}/generated-sources/" />
-                  </target>
-                </configuration>
-              </execution>
-            </executions>
-            <dependencies>
-              <dependency>
-                <groupId>net.sourceforge.fmpp</groupId>
-                <artifactId>fmpp</artifactId>
-                <version>${fmpp.version}</version>
-              </dependency>
-            </dependencies>
-          </plugin>
-          <plugin> <!-- Enforce javacc-maven-plugin executions after 
maven-antrun-plugin -->
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>javacc-maven-plugin</artifactId>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
   </profiles>
 </project>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to