You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by eb...@apache.org on 2021/06/11 18:20:19 UTC

[incubator-streampipes] 11/29: Add query template class (includes database specific templates for various query statements)

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

ebi pushed a commit to branch STREAMPIPES-349
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 3d115538d1455c63741933c21288c6bbd6cdba32
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Fri Jun 11 19:00:47 2021 +0200

    Add query template class (includes database specific templates for various query statements)
---
 .../dataexplorer/v4/template/QueryTemplatesV4.java | 72 ++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java
new file mode 100644
index 0000000..23c2789
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.streampipes.dataexplorer.v4.template;
+
+public class QueryTemplatesV4 {
+
+    public static String selectWildcardFrom(String index) {
+        return "SELECT * FROM " + index;
+    }
+
+    public static String selectAggregationFrom(String index, String aggregationFunction) {
+        return "SELECT " + aggregationFunction + "(*) FROM " + index;
+    }
+
+    public static String deleteFrom(String index) {
+        return "DELETE FROM " + index;
+    }
+
+
+    public static String whereTimeWithin(long startDate, long endDate) {
+        return "WHERE time > "
+                + startDate * 1000000
+                + " AND time < "
+                + endDate * 1000000;
+    }
+
+    public static String whereTimeLeftBound(long startDate) {
+        return "WHERE time > "
+                + startDate * 1000000;
+    }
+
+    public static String whereTimeRightBound(long endDate) {
+        return "WHERE time < "
+                + endDate * 1000000;
+    }
+
+    public static String groupByTags(String tags) {
+        return "GROUP BY " + tags;
+    }
+
+    public static String groupByTime(String timeInterval) {
+        return "GROUP BY time(" + timeInterval + ")";
+    }
+
+    public static String orderByTime(String ordering) {
+        return "ORDER BY time " + ordering.toUpperCase();
+    }
+
+    public static String limitItems(int limit) {
+        return "LIMIT " + limit;
+    }
+
+    public static String offset(int offset) {
+        return "OFFSET " + offset;
+    }
+
+}