ritesh-kapoor commented on a change in pull request #1640: [CALCITE-3552] 
Support MySQL ExtractValue function
URL: https://github.com/apache/calcite/pull/1640#discussion_r355938583
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/test/SqlXmlFunctionsTest.java
 ##########
 @@ -0,0 +1,106 @@
+/*
+ * 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.calcite.test;
+
+import org.apache.calcite.runtime.CalciteException;
+import org.apache.calcite.runtime.SqlFunctions;
+import org.apache.calcite.runtime.XmlFunctions;
+import org.apache.calcite.util.BuiltInMethod;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
+
+/**
+ * Unit test for the methods in {@link SqlFunctions} that implement Xml 
processing functions.
+ */
+public class SqlXmlFunctionsTest {
+
+  @Test
+  public void testExtractValue() {
+    assertExtractValue("<a>ccc<b>ddd</b></a>", "/a", is("ccc"));
+
+    String input = "<a>ccc<b>ddd</b></a>";
+    String message = "Illegal behavior "
+        + "'javax.xml.xpath.XPathExpressionException: 
javax.xml.transform.TransformerException: "
+        + "A location path was expected, but the following token was 
encountered:  #' "
+        + "EXTRACTVALUE: document: '" + input + "', xpath expression: '#'";
+    CalciteException expected = new CalciteException(message, null);
+    assertExtractValueFailed(input, "#", errorMatches(expected));
+  }
+
+  private void assertExtractValue(String input, String xpath,
 
 Review comment:
   Done :)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to