Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>

<artifactId>avatica-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.avatica.util;

/**
* This utility is employed to pass parameters from KE to Avatica
*/
public class CalciteAvaticaParamUtil {
// if a timestamp is compared with a date type, use this parameter to cut off the timestamp
public static final ThreadLocal<Boolean> KYLIN_ALLOW_CALCITE_CUT_OFF_DATE = new ThreadLocal<>();

private CalciteAvaticaParamUtil() {}

}

// End CalciteAvaticaParamUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,14 @@ public static Integer dateStringToUnixDate(String s) {
if (s == null) {
return null;
}
if (CalciteAvaticaParamUtil.KYLIN_ALLOW_CALCITE_CUT_OFF_DATE.get() != null
&& CalciteAvaticaParamUtil.KYLIN_ALLOW_CALCITE_CUT_OFF_DATE.get()) {
s = s.trim();
int spaceIndex = s.indexOf(' ');
if (spaceIndex > 0) {
s = s.substring(0, spaceIndex);
}
}
int hyphen1 = s.indexOf('-');
int y;
int m;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.calcite.avatica.util;

import org.junit.Assert;
import org.junit.Test;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -150,6 +151,18 @@ private void checkDateString(String s, int d) {
assertThat(dateStringToUnixDate(s), is(d));
}

@Test public void testDateCutOff() {
CalciteAvaticaParamUtil.KYLIN_ALLOW_CALCITE_CUT_OFF_DATE.set(true);
assertThat(dateStringToUnixDate("1972-03-01 01:02:03"), is(0 + 365 * 2 + 31 + 29 + (1 - 1)));
CalciteAvaticaParamUtil.KYLIN_ALLOW_CALCITE_CUT_OFF_DATE.set(false);
try {
dateStringToUnixDate("1972-03-01 01:02:03");
} catch (Exception e) {
Assert.assertTrue(e instanceof NumberFormatException);
Assert.assertEquals("For input string: \"01 01:02:03\"", e.getMessage());
}
}

@Test public void testTimeToString() {
checkTimeString("00:00:00", 0, 0);
checkTimeString("23:59:59", 0, 86400000 - 1000);
Expand Down
2 changes: 1 addition & 1 deletion metrics-dropwizardmetrics3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>

<artifactId>avatica-metrics-dropwizardmetrics3</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>

<artifactId>avatica-metrics</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion noop-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>

<artifactId>avatica-noop-driver</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<packaging>pom</packaging>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
<name>Apache Calcite Avatica Project</name>
<description>Avatica is a JDBC driver framework which is a part of Apache Calcite</description>
<url>https://calcite.apache.org/avatica</url>
Expand Down
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>

<artifactId>avatica-server</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion shaded/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion standalone-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>
<artifactId>avatica-standalone-server</artifactId>
<name>Apache Calcite Avatica Standalone Server</name>
Expand Down
2 changes: 1 addition & 1 deletion tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-parent</artifactId>
<version>1.11.0.x-3.x-r2</version>
<version>1.11.0.x-3.x-r3</version>
</parent>

<artifactId>avatica-tck</artifactId>
Expand Down