File tree Expand file tree Collapse file tree
legacy/src/main/java/org/opensearch/sql/legacy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4949import org .opensearch .sql .legacy .domain .hints .HintFactory ;
5050import org .opensearch .sql .legacy .exception .SqlParseException ;
5151import org .opensearch .sql .legacy .query .multi .MultiQuerySelect ;
52+ import org .opensearch .sql .legacy .utils .Util ;
5253
5354/**
5455 * OpenSearch sql support
@@ -411,9 +412,10 @@ public JoinSelect parseJoinSelect(SQLQueryExpr sqlExpr) throws SqlParseException
411412 */
412413 private void validateJoinWithoutAggregations (MySqlSelectQueryBlock query )
413414 throws SqlParseException {
415+ String version = Util .getDocumentationVersion (SqlParser .class );
414416 String errorMessage =
415- "JOIN queries do not support aggregations on the joined result. For more information, see"
416- + " https://docs.opensearch.org/latest /search-plugins/sql/limitation/#join-does-not-support-aggregations-on-the-joined-result" ;
417+ "JOIN queries do not support aggregations on the joined result. For more information, see "
418+ + "https://docs.opensearch.org/" + version + " /search-plugins/sql/limitation/#join-does-not-support-aggregations-on-the-joined-result" ;
417419
418420 if (query .getGroupBy () != null && !query .getGroupBy ().getItems ().isEmpty ()) {
419421 throw new SqlParseException (errorMessage );
Original file line number Diff line number Diff line change @@ -280,4 +280,23 @@ public static SQLExpr toSqlExpr(String sql) {
280280 }
281281 return expr ;
282282 }
283+
284+ /**
285+ * Gets the OpenSearch major.minor version for documentation links.
286+ * Converts "x.y.z" format to "x.y".
287+ *
288+ * @param clazz The class to get package implementation version from
289+ * @return The major.minor version string, or "latest" if version cannot be determined
290+ */
291+ public static String getDocumentationVersion (Class <?> clazz ) {
292+ String version = clazz .getPackage ().getImplementationVersion ();
293+ if (version == null ) {
294+ return "latest" ;
295+ }
296+ String [] parts = version .split ("\\ ." );
297+ if (parts .length >= 2 ) {
298+ return parts [0 ] + "." + parts [1 ];
299+ }
300+ return "latest" ;
301+ }
283302}
You can’t perform that action at this time.
0 commit comments