You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/06/28 14:50:20 UTC

[GitHub] [pinot] walterddr commented on a diff in pull request #8965: Support JSON column type in recommender.

walterddr commented on code in PR #8965:
URL: https://github.com/apache/pinot/pull/8965#discussion_r908576990


##########
pinot-controller/src/test/resources/recommenderInput/SegmentSizeRuleInput.json:
##########
@@ -131,7 +139,8 @@
     "select j from tableName where (a=3 and (h = 5 or f >34) and REGEXP_LIKE(i, 'as*')) or ((f = 3  or j in ('#VALUES', 4)) and REGEXP_LIKE(d, 'fl*'))": 2,
     "select f from tableName where (a=0 or (b=1 and (e in ('#VALUES',2) or c=7))) and TEXT_MATCH(d, 'dasd') and MAX(MAX(h,i),j)=4 and t<3": 4,
     "select f from tableName where (a=0 and b=1) or c=7 or (d = 7 and e =1)": 2,
-    "select f from tableName where t between 1 and 1000": 2
+    "select f from tableName where t between 1 and 1000": 2,
+    "select q from tableName where JSON_MATCH(q, '\"$.a\" IS NOT NULL')": 1

Review Comment:
   - do we plan to do other predicates like EQUAL, GREATER_THAN, STRING match, or the result doesn't matter on the type of predicates?
   - do we plan to have nested level of inquiry in JSON keys like `$.a.b[*].c`, or the result doesn't matter on the level of nested keys?



##########
pinot-controller/src/test/java/org/apache/pinot/controller/recommender/data/generator/JsonGeneratorTest.java:
##########
@@ -0,0 +1,68 @@
+/**
+ * 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.pinot.controller.recommender.data.generator;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class JsonGeneratorTest {
+
+  @Test
+  public void testNext()
+      throws IOException {
+    // JsonGenerator generates empty json when size is less than JsonGenerator.DEFAULT_JSON_ELEMENT_LENGTH
+    JsonGenerator jsonGenerator1 = new JsonGenerator(0);
+    Assert.assertEquals(jsonGenerator1.next(), "{}");
+
+    JsonGenerator jsonGenerator2 = new JsonGenerator(4);
+    Assert.assertEquals(jsonGenerator2.next(), "{}");
+
+    JsonGenerator jsonGenerator3 = new JsonGenerator(8);
+    checkJson((String) jsonGenerator3.next(), 8);
+
+    JsonGenerator jsonGenerator4 = new JsonGenerator(20);
+    checkJson((String) jsonGenerator4.next(), 20);
+  }
+
+  public static void checkJson(String jsonString, int desiredLength)
+      throws IOException {
+
+    // Number of expected elements in the generated JSON string
+    int elementCount = desiredLength / JsonGenerator.DEFAULT_JSON_ELEMENT_LENGTH;
+
+    // Remove escape characters from jsonString for verification purposes. Escape character were added before comma
+    // since json string is written to a CSV file where comma is used as delimiter.
+    jsonString = StringUtils.remove(jsonString, "\\");

Review Comment:
   why are we writing the JSON into a CSV file? doesn't that mean the JSON generated here is single-level depth? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org