You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2022/03/02 19:10:34 UTC
[empire-db] branch master updated: EMPIREDB-362 added stragg function
This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/master by this push:
new d394f0a EMPIREDB-362 added stragg function
d394f0a is described below
commit d394f0abf4cd210970572982018276b49577ae1c
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Wed Mar 2 20:10:33 2022 +0100
EMPIREDB-362 added stragg function
---
empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java | 10 ++++++++++
.../src/main/java/org/apache/empire/dbms/DBSqlPhrase.java | 6 ++++++
.../java/org/apache/empire/dbms/oracle/DBMSHandlerOracle.java | 1 +
3 files changed, 17 insertions(+)
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java b/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
index 8cccc1e..63b0270 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
@@ -1090,6 +1090,16 @@ public abstract class DBColumnExpr extends DBExpr
}
/**
+ * Creates and returns string aggregation expression
+ * @param separator the separator between string
+ * @return the new DBFuncExpr object
+ */
+ public DBColumnExpr strAgg(String separator)
+ {
+ return getExprFromPhrase(DBSqlPhrase.SQL_FUNC_STRAGG, new Object[] { separator });
+ }
+
+ /**
* Creates and returns an expression for the SQL "count()" function
* which returns the number of rows in the result set.
*
diff --git a/empire-db/src/main/java/org/apache/empire/dbms/DBSqlPhrase.java b/empire-db/src/main/java/org/apache/empire/dbms/DBSqlPhrase.java
index 1225ab9..ae94efe 100644
--- a/empire-db/src/main/java/org/apache/empire/dbms/DBSqlPhrase.java
+++ b/empire-db/src/main/java/org/apache/empire/dbms/DBSqlPhrase.java
@@ -1,5 +1,10 @@
package org.apache.empire.dbms;
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBColumnExpr;
+import org.apache.empire.db.expr.column.DBFuncExpr;
+
/**
* Enum for all SQL phrases that may be supplied by the dbms
* @author rainer
@@ -65,6 +70,7 @@ public enum DBSqlPhrase
SQL_FUNC_MAX ("max(?)", true),
SQL_FUNC_MIN ("min(?)", true),
SQL_FUNC_AVG ("avg(?)", true),
+ SQL_FUNC_STRAGG ("string_agg(?,{0})", true), // string_agg, LISTAGG
// Decode
SQL_FUNC_DECODE ("case ? {0} end"), // Oracle: decode(? {0})
diff --git a/empire-db/src/main/java/org/apache/empire/dbms/oracle/DBMSHandlerOracle.java b/empire-db/src/main/java/org/apache/empire/dbms/oracle/DBMSHandlerOracle.java
index 3756b6f..6495984 100644
--- a/empire-db/src/main/java/org/apache/empire/dbms/oracle/DBMSHandlerOracle.java
+++ b/empire-db/src/main/java/org/apache/empire/dbms/oracle/DBMSHandlerOracle.java
@@ -221,6 +221,7 @@ public class DBMSHandlerOracle extends DBMSHandlerBase
case SQL_FUNC_MAX: return "max(?)";
case SQL_FUNC_MIN: return "min(?)";
case SQL_FUNC_AVG: return "avg(?)";
+ case SQL_FUNC_STRAGG: return "listagg(? {0})";
// Others
case SQL_FUNC_DECODE: return "decode(? {0})";
case SQL_FUNC_DECODE_SEP: return ",";