/*
* 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.avatica.util.Casing;
import org.apache.calcite.avatica.util.Quoting;
import org.apache.calcite.avatica.util.TimeUnit;
import org.apache.calcite.config.Lex;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeSystem;
import org.apache.calcite.runtime.CalciteContextException;
import org.apache.calcite.sql.SqlCollation;
import org.apache.calcite.sql.SqlIdentifier;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.SqlOperatorTable;
import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.SqlSpecialOperator;
import org.apache.calcite.sql.fun.SqlLibrary;
import org.apache.calcite.sql.fun.SqlLibraryOperatorTableFactory;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParseException;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.sql.type.ArraySqlType;
import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.type.SqlTypeUtil;
import org.apache.calcite.sql.util.SqlShuttle;
import org.apache.calcite.sql.validate.SelectScope;
import org.apache.calcite.sql.validate.SqlAbstractConformance;
import org.apache.calcite.sql.validate.SqlConformance;
import org.apache.calcite.sql.validate.SqlConformanceEnum;
import org.apache.calcite.sql.validate.SqlDelegatingConformance;
import org.apache.calcite.sql.validate.SqlMonotonicity;
import org.apache.calcite.sql.validate.SqlValidator;
import org.apache.calcite.sql.validate.SqlValidatorCatalogReader;
import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
import org.apache.calcite.test.catalog.CountingFactory;
import org.apache.calcite.testlib.annotations.LocaleEnUs;
import org.apache.calcite.tools.ValidationException;
import org.apache.calcite.util.Bug;
import org.apache.calcite.util.ImmutableBitSet;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import static org.apache.calcite.test.Matchers.isCharset;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static java.util.Arrays.asList;
/**
* Concrete child class of {@link SqlValidatorTestCase}, containing lots of unit
* tests.
*
* <p>If you want to run these same tests in a different environment, create a
* derived class whose {@link #fixture()} returns a different implementation of
* {@link SqlValidatorFixture}.
*/
@LocaleEnUs
public class SqlValidatorTest extends SqlValidatorTestCase {
//~ Static fields/initializers ---------------------------------------------
// CHECKSTYLE: IGNORE 1
/**
* @deprecated Deprecated so that usages of this constant will show up in
* yellow in Intellij and maybe someone will fix them.
*/
protected static final boolean TODO = false;
private static final String ANY = "(?s).*";
protected static final Logger LOGGER =
LoggerFactory.getLogger(SqlValidatorTest.class);
private static final String ERR_IN_VALUES_INCOMPATIBLE =
"Values in expression list must have compatible types";
private static final String ERR_IN_OPERANDS_INCOMPATIBLE =
"Values passed to IN operator must have compatible types";
private static final String ERR_AGG_IN_GROUP_BY =
"Aggregate expression is illegal in GROUP BY clause";
private static final String ERR_AGG_IN_ORDER_BY =
"Aggregate expression is illegal in ORDER BY clause of non-aggregating SELECT";
private static final String ERR_NESTED_AGG =
"Aggregate expressions cannot be nested";
private static final String EMP_RECORD_TYPE =
"RecordType(INTEGER NOT NULL EMPNO,"
+ " VARCHAR(20) NOT NULL ENAME,"
+ " VARCHAR(10) NOT NULL JOB,"
+ " INTEGER MGR,"
+ " TIMESTAMP(0) NOT NULL HIREDATE,"
+ " INTEGER NOT NULL SAL,"
+ " INTEGER NOT NULL COMM,"
+ " INTEGER NOT NULL DEPTNO,"
+ " BOOLEAN NOT NULL SLACKER) NOT NULL";
private static final String STR_AGG_REQUIRES_MONO = "Streaming aggregation "
+ "requires at least one monotonic expression in GROUP BY clause";
private static final String STR_ORDER_REQUIRES_MONO =
"Streaming ORDER BY must start with monotonic expression";
private static final String STR_SET_OP_INCONSISTENT =
"Set operator cannot combine streaming and non-streaming inputs";
private static final String ROW_RANGE_NOT_ALLOWED_WITH_RANK =
"ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions";
private static final String RANK_REQUIRES_ORDER_BY = "RANK or DENSE_RANK "
+ "functions require ORDER BY clause in window specification";
private static String cannotConvertToStream(String name) {
return "Cannot convert table '" + name + "' to stream";
}
private static String cannotConvertToRelation(String table) {
return "Cannot convert stream '" + table + "' to relation";
}
private static String cannotStreamResultsForNonStreamingInputs(String inputs) {
return "Cannot stream results of a query with no streaming inputs: '"
+ inputs
+ "'. At least one input should be convertible to a stream";
}
static SqlOperatorTable operatorTableFor(SqlLibrary library) {
return SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
SqlLibrary.STANDARD, library);
}
@Test void testMultipleSameAsPass() {
sql("select 1 as again,2 as \"again\", 3 as AGAiN from (values (true))")
.ok();
}
@Test void testMultipleDifferentAs() {
sql("select 1 as c1,2 as c2 from (values(true))").ok();
}
@Test void testTypeOfAs() {
sql("select 1 as c1 from (values (true))")
.columnType("INTEGER NOT NULL");
sql("select 'hej' as c1 from (values (true))")
.columnType("CHAR(3) NOT NULL");
sql("select x'deadbeef' as c1 from (values (true))")
.columnType("BINARY(4) NOT NULL");
sql("select cast(null as boolean) as c1 from (values (true))")
.columnType("BOOLEAN");
}
@Test void testTypesLiterals() {
没有合适的资源?快使用搜索试试~ 我知道了~
calcite.zip
共2000个文件
java:1814个
md:80个
json:32个
需积分: 5 0 下载量 178 浏览量
2023-08-18
20:00:04
上传
评论
收藏 7.5MB ZIP 举报
温馨提示
Apache Calcite是一个动态数据管理框架。 它包含了许多组成典型 数据库管理系统,但省略了存储原语。 它提供了一个行业标准的SQL解析器和验证器, 具有可插入规则和成本函数的可定制优化器, 逻辑和物理代数运算符,各种变换 从SQL到代数(以及相反的)的算法,以及许多 用于在Cassandra、Druid等上执行SQL查询的适配器, Elasticsearch、MongoDB、Kafka等配置
资源推荐
资源详情
资源评论
收起资源包目录
calcite.zip (2000个子文件)
viz-template.html 13KB
index.html 4KB
news_item.html 2KB
section_nav.html 2KB
news_item.html 2KB
docs_ul.html 2KB
EMPS.html 1KB
tableX2.html 1KB
index.html 1KB
DEPTS.html 1KB
tableOK.html 1KB
news_contents.html 1KB
tableNoTheadTbody.html 1KB
anchor_links.html 1KB
tableNoTH.html 997B
index.html 945B
primary-nav-items.html 781B
footer.html 642B
docs_option.html 549B
top.html 508B
docs_contents_mobile.html 482B
news_contents_mobile.html 440B
docs.html 407B
header.html 398B
news.html 291B
page.html 257B
docs_contents.html 213B
external.html 211B
default.html 169B
SqlValidatorTest.java 509KB
JdbcTest.java 367KB
RelToSqlConverterTest.java 272KB
RelOptRulesTest.java 261KB
SqlValidatorImpl.java 245KB
DruidAdapterIT.java 230KB
SqlToRelConverter.java 226KB
DruidAdapter2IT.java 196KB
RelBuilderTest.java 184KB
RelBuilder.java 164KB
RelOptUtil.java 162KB
RexImpTable.java 148KB
SqlToRelConverterTest.java 147KB
RelMetadataTest.java 135KB
RexProgramTest.java 129KB
RelDecorrelator.java 110KB
UtilTest.java 109KB
RexSimplify.java 106KB
RexUtil.java 101KB
SqlFunctions.java 93KB
SqlStdOperatorTable.java 88KB
Util.java 87KB
SubstitutionVisitor.java 86KB
SqlImplementor.java 76KB
PlannerTest.java 76KB
LoptOptimizeJoinRule.java 74KB
StandardConvertletTable.java 72KB
MaterializedViewSubstitutionVisitorTest.java 71KB
DruidQuery.java 70KB
ConcurrentTestCommandScript.java 66KB
RexBuilder.java 60KB
SqlDialect.java 60KB
RexToLixTranslator.java 60KB
MaterializedViewRelOptRulesTest.java 59KB
MaterializedViewRule.java 59KB
SqlAdvisorTest.java 57KB
SqlTypeUtil.java 55KB
RelWriterTest.java 55KB
EnumerablesTest.java 54KB
VolcanoPlanner.java 53KB
Mappings.java 51KB
CalcitePrepareImpl.java 50KB
SqlValidatorUtil.java 50KB
JdbcAdapterTest.java 50KB
RelFieldTrimmer.java 50KB
RelToSqlConverter.java 47KB
ReduceExpressionsRule.java 46KB
SqlPrettyWriter.java 45KB
EnumUtils.java 45KB
UdfTest.java 44KB
SqlUtil.java 44KB
ReduceDecimalsRule.java 44KB
CalciteResource.java 43KB
SqlFunctionsTest.java 43KB
RexLiteral.java 41KB
LatticeTest.java 41KB
Lattice.java 40KB
RelStructuredTypeFlattener.java 40KB
ConcurrentTestCommandGenerator.java 39KB
MaterializedViewAggregateRule.java 39KB
FileAdapterTest.java 39KB
JdbcRules.java 39KB
Resources.java 38KB
ImmutableBitSet.java 38KB
EnumerableWindow.java 37KB
AggregateExpandDistinctAggregatesRule.java 37KB
BuiltInMethod.java 37KB
TypeCoercionTest.java 37KB
VolcanoPlannerTest.java 37KB
SqlIntervalQualifier.java 37KB
ReturnTypes.java 37KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
hello_中年人
- 粉丝: 7
- 资源: 324
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功