未验证 提交 ae2a5ea2 编写于 作者: J JingShang Lu 提交者: GitHub

add support for test of Join Table (#5020)

* add support for test of Join Table

* fix comment

* format code

* fix

* fix

* fix

* replace table assert with tableReference assert

* delete getSimpleTables

* fix

* fix

* fix

* rename getTables to getSimpleTableSegments

* fix for fun name

* delete <tables>

* delete some comment
Co-authored-by: Nlujingshang1 <lujingshang1@jd.com>
上级 7d7ae298
......@@ -18,6 +18,6 @@
<sql-cases>
<sql-case id="select_inner_join_related_with_alias" value="SELECT i.* FROM t_order o INNER JOIN t_order_item i ON o.order_id = i.order_id WHERE o.order_id = ?" />
<sql-case id="select_inner_join_related_with_name" value="SELECT t_order_item.* FROM t_order JOIN t_order_item ON t_order.order_id = t_order_item.order_id WHERE t_order.order_id = ?" db-types="MySQL"/>
<sql-case id="select_inner_join_related_with_name" value="SELECT t_order_item.* FROM t_order JOIN t_order_item ON t_order.order_id = t_order_item.order_id WHERE t_order.order_id = ?" />
<sql-case id="select_join_using" value="SELECT i.* FROM t_order o JOIN t_order_item i USING(order_id) WHERE o.order_id = ?" db-types="MySQL,PostgreSQL" />
</sql-cases>
......@@ -35,7 +35,7 @@
<sql-case id="select_sharding_route_with_binding_tables" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? ORDER BY i.item_id" />
<sql-case id="select_full_route_with_binding_tables" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id ORDER BY i.item_id" />
<!--TODO Need to verify case insensitivity of table names in sharding rule-->
<sql-case id="select_sharding_route_with_broadcast_table" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id JOIN t_broadcast_table c ON o.status = c.status WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? AND o.status = ? ORDER BY i.item_id" db-types="MySQL" />
<sql-case id="select_sharding_route_with_broadcast_table" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id JOIN t_broadcast_table c ON o.status = c.status WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? AND o.status = ? ORDER BY i.item_id" />
<sql-case id="select_keyword_table_name_with_back_quotes" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id JOIN `select` c ON o.status = c.status WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? AND o.status = ? ORDER BY i.item_id" db-types="MySQL" />
<sql-case id="select_keyword_table_name_with_double_quotes" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id JOIN &quot;select&quot; c ON o.status = c.status WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? AND c.status = ? ORDER BY i.item_id" db-types="PostgreSQL,Oracle" />
<sql-case id="select_keyword_table_name_with_square_brackets" value="SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id JOIN [select] c ON o.status = c.status WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? AND c.status = ? ORDER BY i.item_id" db-types="SQLServer" />
......
......@@ -22,6 +22,8 @@ import lombok.Setter;
import org.apache.shardingsphere.sql.parser.sql.segment.SQLSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.PredicateSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.OwnerSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
import java.util.Collection;
import java.util.LinkedList;
......@@ -37,4 +39,23 @@ public final class JoinSpecificationSegment implements SQLSegment {
private PredicateSegment predicateSegment;
private Collection<ColumnSegment> usingColumns = new LinkedList<>();
/**
* get tables.
* @return tables.
*/
public Collection<SimpleTableSegment> getSimpleTableSegments() {
Collection<SimpleTableSegment> tables = new LinkedList<>();
if (null != predicateSegment) {
if (null != predicateSegment.getColumn() && (predicateSegment.getColumn().getOwner().isPresent())) {
OwnerSegment ownerSegment = predicateSegment.getColumn().getOwner().get();
tables.add(new SimpleTableSegment(ownerSegment.getStartIndex(), ownerSegment.getStopIndex(), ownerSegment.getIdentifier()));
}
if (null != predicateSegment.getRightValue() && (predicateSegment.getRightValue() instanceof ColumnSegment) && ((ColumnSegment) predicateSegment.getRightValue()).getOwner().isPresent()) {
OwnerSegment ownerSegment = ((ColumnSegment) predicateSegment.getRightValue()).getOwner().get();
tables.add(new SimpleTableSegment(ownerSegment.getStartIndex(), ownerSegment.getStopIndex(), ownerSegment.getIdentifier()));
}
}
return tables;
}
}
......@@ -21,7 +21,9 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.sql.segment.SQLSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.TableSegment;
import java.util.Collection;
import java.util.LinkedList;
@Getter
@Setter
......@@ -39,12 +41,14 @@ public final class JoinedTableSegment implements SQLSegment {
* get table.
* @return tableSegment.
*/
public TableSegment getTable() {
if (null != tableFactor.getTable()) {
if (tableFactor.getTable() instanceof SimpleTableSegment) {
return tableFactor.getTable();
}
public Collection<SimpleTableSegment> getSimpleTableSegments() {
Collection<SimpleTableSegment> tables = new LinkedList<>();
if (null != tableFactor) {
tables.addAll(tableFactor.getSimpleTableSegments());
}
if (null != joinSpecification) {
tables.addAll(joinSpecification.getSimpleTableSegments());
}
return null;
return tables;
}
}
......@@ -21,6 +21,7 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.sql.segment.SQLSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.TableSegment;
import java.util.Collection;
......@@ -39,4 +40,21 @@ public final class TableFactorSegment implements SQLSegment {
private final Collection<ColumnSegment> columns = new LinkedList<>();
private Collection<TableReferenceSegment> tableReferences = new LinkedList<>();
/**
* get tables.
* @return tables.
*/
public Collection<SimpleTableSegment> getSimpleTableSegments() {
Collection<SimpleTableSegment> tables = new LinkedList<>();
if (null != table && table instanceof SimpleTableSegment) {
tables.add((SimpleTableSegment) table);
}
if (null != tableReferences && !tableReferences.isEmpty()) {
for (TableReferenceSegment each: tableReferences) {
tables.addAll(each.getTables());
}
}
return tables;
}
}
......@@ -44,16 +44,11 @@ public final class TableReferenceSegment implements SQLSegment {
public Collection<SimpleTableSegment> getTables() {
Collection<SimpleTableSegment> tables = new LinkedList<>();
if (null != tableFactor) {
if (tableFactor.getTable() instanceof SimpleTableSegment) {
tables.add((SimpleTableSegment) tableFactor.getTable());
}
tables.addAll(tableFactor.getSimpleTableSegments());
}
if (!joinedTables.isEmpty()) {
for (JoinedTableSegment each : joinedTables) {
if (null != each.getTable()) {
tables.add((SimpleTableSegment) each.getTable());
}
tables.addAll(each.getSimpleTableSegments());
}
}
return tables;
......
/*
* 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.shardingsphere.sql.parser.integrate.asserts.segment;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.integrate.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.ExpectedJoinSpecification;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.JoinSpecificationSegment;
/**
* JoinSpecification assert.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class JoinSpecificationAssert {
/**
* Assert actual JoinSpecification segments is correct with expected JoinSpecification.
*
* @param assertContext assert context
* @param actual actual JoinSpecification
* @param expected expected JoinSpecification
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final JoinSpecificationSegment actual, final ExpectedJoinSpecification expected) {
}
}
/*
* 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.shardingsphere.sql.parser.integrate.asserts.segment;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.integrate.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.table.JoinTableAssert;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.table.TableFactorAssert;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.ExpectedTableReference;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table.ExpectedJoinTable;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.JoinedTableSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.TableReferenceSegment;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* TableReferences assert.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class TableReferencesAssert {
/**
* Assert actual TableReferences segments is correct with expected TableReferences.
*
* @param assertContext assert context
* @param actual actual TableReferences
* @param expected expected TableReferences
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final List<TableReferenceSegment> actual, final List<ExpectedTableReference> expected) {
assertThat(assertContext.getText("TableReferences assert error"), actual.size(), is(null == expected ? 0 : expected.size()));
for (int i = 0; i < actual.size(); i++) {
TableFactorAssert.assertIs(assertContext, actual.get(i).getTableFactor(), expected.get(i).getTableFactor());
JoinTableAssert.assertIs(assertContext, (List<JoinedTableSegment>) actual.get(i).getJoinedTables(), (List<ExpectedJoinTable>) expected.get(i).getJoinTables());
}
}
}
/*
* 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.shardingsphere.sql.parser.integrate.asserts.segment.table;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.integrate.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.JoinSpecificationAssert;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table.ExpectedJoinTable;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.JoinedTableSegment;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* JoinTable assert.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class JoinTableAssert {
/**
* Assert actual joinTable segments is correct with expected joinTables.
*
* @param assertContext assert context
* @param actual actual joinTables
* @param expected expected joinTables
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final JoinedTableSegment actual, final ExpectedJoinTable expected) {
TableFactorAssert.assertIs(assertContext, actual.getTableFactor(), expected.getTableFactor());
JoinSpecificationAssert.assertIs(assertContext, actual.getJoinSpecification(), expected.getJoinSpecification());
}
public static void assertIs(final SQLCaseAssertContext assertContext, final List<JoinedTableSegment> actual, final List<ExpectedJoinTable> expected) {
assertThat(assertContext.getText("JoinTable size assert error"), actual.size(), is(null == expected ? 0 : expected.size()));
for (int i = 0; i < actual.size(); i++) {
TableFactorAssert.assertIs(assertContext, actual.get(i).getTableFactor(), expected.get(i).getTableFactor());
JoinSpecificationAssert.assertIs(assertContext, actual.get(i).getJoinSpecification(), expected.get(i).getJoinSpecification());
}
}
}
/*
* 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.shardingsphere.sql.parser.integrate.asserts.segment.table;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.integrate.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.TableReferencesAssert;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.ExpectedTableReference;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table.ExpectedTableFactor;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.TableFactorSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.TableReferenceSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
import java.util.List;
/**
* TableFactor assert.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class TableFactorAssert {
/**
* Assert actual TableFactor segments is correct with expected TableFactor.
*
* @param assertContext assert context
* @param actual actual TableFactor
* @param expected expected TableFactor
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final TableFactorSegment actual, final ExpectedTableFactor expected) {
if (null != actual.getTable() && actual.getTable() instanceof SimpleTableSegment) {
TableAssert.assertIs(assertContext, (SimpleTableSegment) actual.getTable(), expected.getTable());
}
TableReferencesAssert.assertIs(assertContext, (List<TableReferenceSegment>) actual.getTableReferences(), (List<ExpectedTableReference>) expected.getExpectedTableReferences());
}
}
......@@ -21,6 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.integrate.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.SQLSegmentAssert;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.TableReferencesAssert;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.groupby.GroupByClauseAssert;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.limit.LimitClauseAssert;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.orderby.OrderByClauseAssert;
......@@ -28,10 +29,12 @@ import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.projection
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.table.TableAssert;
import org.apache.shardingsphere.sql.parser.integrate.asserts.segment.where.WhereClauseAssert;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.statement.dml.SelectStatementTestCase;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.TableReferenceSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.pagination.limit.LimitSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import static org.junit.Assert.assertFalse;
......@@ -52,11 +55,15 @@ public final class SelectStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final SelectStatement actual, final SelectStatementTestCase expected) {
assertProjection(assertContext, actual, expected);
assertTable(assertContext, actual, expected);
assertWhereClause(assertContext, actual, expected);
assertGroupByClause(assertContext, actual, expected);
assertOrderByClause(assertContext, actual, expected);
assertLimitClause(assertContext, actual, expected);
assertTableReferences(assertContext, actual, expected);
}
private static void assertTableReferences(final SQLCaseAssertContext assertContext, final SelectStatement actual, final SelectStatementTestCase expected) {
TableReferencesAssert.assertIs(assertContext, (List<TableReferenceSegment>) actual.getTableReferences(), expected.getTableReferences());
}
private static void assertProjection(final SQLCaseAssertContext assertContext, final SelectStatement actual, final SelectStatementTestCase expected) {
......
/*
* 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.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.AbstractExpectedDelimiterSQLSegment;
import javax.xml.bind.annotation.XmlAttribute;
/**
* Expected JoinSpecification.
*/
@Getter
@Setter
public final class ExpectedJoinSpecification extends AbstractExpectedDelimiterSQLSegment {
@XmlAttribute
private String expr;
@XmlAttribute
private String columus;
}
/*
* 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.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.AbstractExpectedDelimiterSQLSegment;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table.ExpectedJoinTable;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table.ExpectedTableFactor;
import javax.xml.bind.annotation.XmlElement;
import java.util.Collection;
/**
* Expected TableReference.
*/
@Getter
@Setter
public final class ExpectedTableReference extends AbstractExpectedDelimiterSQLSegment {
@XmlElement(name = "table-factor")
private ExpectedTableFactor tableFactor;
@XmlElement(name = "join-table")
private Collection<ExpectedJoinTable> joinTables;
}
/*
* 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.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.AbstractExpectedDelimiterSQLSegment;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.ExpectedJoinSpecification;
import javax.xml.bind.annotation.XmlElement;
/**
* Expected JoinTable.
*/
@Getter
@Setter
public final class ExpectedJoinTable extends AbstractExpectedDelimiterSQLSegment {
@XmlElement(name = "table-factor")
private ExpectedTableFactor tableFactor;
@XmlElement
private ExpectedJoinSpecification joinSpecification;
}
/*
* 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.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.table;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.AbstractExpectedDelimiterSQLSegment;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.ExpectedTableReference;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.expr.simple.ExpectedSubquery;
import javax.xml.bind.annotation.XmlElement;
import java.util.Collection;
/**
* Expected TableFactor.
*/
@Getter
@Setter
public final class ExpectedTableFactor extends AbstractExpectedDelimiterSQLSegment {
@XmlElement
private ExpectedSimpleTable table;
@XmlElement
private ExpectedSubquery subquery;
@XmlElement(name = "table-reference")
private Collection<ExpectedTableReference> expectedTableReferences;
}
......@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.statement.dml
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.ExpectedTableReference;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.limit.ExpectedLimitClause;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.orderby.ExpectedOrderByClause;
import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.predicate.ExpectedWhereClause;
......@@ -28,6 +29,7 @@ import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.statement.SQLP
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import java.util.List;
/**
* Select statement test case.
......@@ -39,6 +41,9 @@ public final class SelectStatementTestCase extends SQLParserTestCase {
@XmlAttribute(name = "lock-clause")
private boolean lockClause;
@XmlElement(name = "table-reference")
private List<ExpectedTableReference> tableReferences;
@XmlElement(name = "tables")
private final ExpectedTables tables = new ExpectedTables();
......
......@@ -18,27 +18,33 @@
<sql-parser-test-cases>
<select sql-case-id="select_sum">
<tables>
<simple-table name="t_order" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<aggregation-projection type="SUM" inner-expression-start-index="10" alias="user_id_sum" start-index="7" stop-index="18" />
</projections>
</select>
<select sql-case-id="select_count">
<tables>
<simple-table name="t_order" start-index="37" stop-index="43" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="37" stop-index="43" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="30">
<aggregation-projection type="COUNT" alias="orders_count" inner-expression-start-index="12" start-index="7" stop-index="14" />
</projections>
</select>
<select sql-case-id="select_count_with_sub">
<tables>
<simple-table name="t_order" start-index="37" stop-index="43" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="37" stop-index="43" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="30">
<aggregation-projection type="COUNT" alias="orders_count" inner-expression-start-index="12" start-index="7" stop-index="14" />
</projections>
......@@ -56,9 +62,11 @@
</select>
<select sql-case-id="select_count_with_sub_with_whitespace">
<tables>
<simple-table name="t_order" start-index="37" stop-index="43" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="37" stop-index="43" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="30">
<aggregation-projection type="COUNT" alias="orders_count" inner-expression-start-index="12" start-index="7" stop-index="14" />
</projections>
......@@ -76,37 +84,49 @@
</select>
<select sql-case-id="select_max">
<tables>
<simple-table name="t_order" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<aggregation-projection type="MAX" inner-expression-start-index="10" alias="max_user_id" start-index="7" stop-index="18" />
</projections>
</select>
<select sql-case-id="select_min">
<tables>
<simple-table name="t_order" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<aggregation-projection type="MIN" inner-expression-start-index="10" alias="min_user_id" start-index="7" stop-index="18" />
</projections>
</select>
<select sql-case-id="select_avg">
<tables>
<simple-table name="t_order" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<aggregation-projection type="AVG" inner-expression-start-index="10" alias="user_id_avg" start-index="7" stop-index="18" />
</projections>
</select>
<select sql-case-id="select_count_with_binding_tables_without_join" parameters="1, 2, 9, 10">
<tables>
<simple-table name="t_order" alias="o" start-index="36" stop-index="42" />
<simple-table name="t_order_item" alias="i" start-index="47" stop-index="58" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="36" stop-index="42" />
</table-factor>
</table-reference>
<table-reference>
<table-factor>
<table name="t_order_item" alias="i" start-index="47" stop-index="58" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="29">
<aggregation-projection type="COUNT" inner-expression-start-index="12" alias="items_count" start-index="7" stop-index="14" />
</projections>
......@@ -155,10 +175,16 @@
</select>
<select sql-case-id="select_count_with_binding_tables_with_join" parameters="1, 2, 9, 10">
<tables>
<simple-table name="t_order" alias="o" start-index="36" stop-index="42" />
<simple-table name="t_order_item" alias="i" start-index="51" stop-index="62" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="36" stop-index="42" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="51" stop-index="62" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="29">
<aggregation-projection type="COUNT" inner-expression-start-index="12" alias="items_count" start-index="7" stop-index="14" />
</projections>
......@@ -191,9 +217,11 @@
</select>
<select sql-case-id="select_count_with_escape_character">
<tables>
<simple-table name="t_order" start-index="46" stop-index="52" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="46" stop-index="52" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="39">
<aggregation-projection type="COUNT" inner-expression-start-index="12" alias="orders_count" start-index="7" stop-index="23" />
</projections>
......
......@@ -33,9 +33,11 @@
</select>
<select sql-case-id="select_with_date_function">
<tables>
<simple-table name="t_order_item" alias="i" start-delimiter="`" end-delimiter="`" start-index="51" stop-index="64" />
</tables>
<table-reference>
<table-factor>
<table name="t_order_item" alias="i" start-delimiter="`" end-delimiter="`" start-index="51" stop-index="64" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="44">
<expression-projection alias="creation_date" start-index="7" stop-index="27" />
</projections>
......@@ -45,9 +47,11 @@
</select>
<select sql-case-id="select_with_regexp" parameters="'init', 1, 2">
<tables>
<simple-table name="t_order_item" alias="t" start-index="14" stop-index="25" />
</tables>
<table-reference>
<table-factor>
<table name="t_order_item" alias="t" start-index="14" stop-index="25" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......
......@@ -18,9 +18,11 @@
<sql-parser-test-cases>
<select sql-case-id="select_group_by_with_sum">
<tables>
<simple-table name="t_order" start-index="49" stop-index="55" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="49" stop-index="55" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="42">
<aggregation-projection type="SUM" alias="orders_sum" inner-expression-start-index="10" start-index="7" stop-index="19" />
<column-projection name="user_id" start-index="36" stop-index="42" />
......@@ -34,9 +36,11 @@
</select>
<select sql-case-id="select_group_by_with_count">
<tables>
<simple-table name="t_order" start-index="53" stop-index="59" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="53" stop-index="59" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="46">
<aggregation-projection type="COUNT" alias="orders_count" inner-expression-start-index="12" start-index="7" stop-index="21" />
<column-projection name="user_id" start-index="40" stop-index="46" />
......@@ -50,9 +54,11 @@
</select>
<select sql-case-id="select_group_by_with_max">
<tables>
<simple-table name="t_order" start-index="51" stop-index="57" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="51" stop-index="57" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="44">
<aggregation-projection type="MAX" alias="max_order_id" inner-expression-start-index="10" start-index="7" stop-index="19" />
<column-projection name="user_id" start-index="38" stop-index="44" />
......@@ -66,9 +72,11 @@
</select>
<select sql-case-id="select_group_by_with_min">
<tables>
<simple-table name="t_order" start-index="51" stop-index="57" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="51" stop-index="57" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="44">
<aggregation-projection type="MIN" alias="min_order_id" inner-expression-start-index="10" start-index="7" stop-index="19" />
<column-projection name="user_id" start-index="38" stop-index="44" />
......@@ -82,9 +90,11 @@
</select>
<select sql-case-id="select_group_by_with_avg">
<tables>
<simple-table name="t_order" start-index="49" stop-index="55" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="49" stop-index="55" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="42">
<aggregation-projection type="AVG" alias="orders_avg" inner-expression-start-index="10" start-index="7" stop-index="19" />
<column-projection name="user_id" start-index="36" stop-index="42" />
......@@ -98,9 +108,11 @@
</select>
<select sql-case-id="select_group_by_with_order_by_desc">
<tables>
<simple-table name="t_order" start-index="49" stop-index="55" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="49" stop-index="55" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="42">
<aggregation-projection type="SUM" inner-expression-start-index="10" alias="orders_sum" start-index="7" stop-index="19" />
<column-projection name="user_id" start-index="36" stop-index="42" />
......@@ -114,10 +126,16 @@
</select>
<select sql-case-id="select_group_by_without_grouped_column" parameters="1, 2, 9, 10">
<tables>
<simple-table name="t_order" alias="o" start-index="36" stop-index="42" />
<simple-table name="t_order_item" alias="i" start-index="51" stop-index="62" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="36" stop-index="42" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="51" stop-index="62"/>
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="29">
<aggregation-projection type="COUNT" inner-expression-start-index="12" alias="items_count" start-index="7" stop-index="14" />
</projections>
......@@ -155,9 +173,11 @@
</select>
<select sql-case-id="select_group_by_with_limit" parameters="5">
<tables>
<simple-table name="t_order" start-index="20" stop-index="26" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="20" stop-index="26" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="13">
<column-projection name="user_id" start-index="7" stop-index="13" />
</projections>
......@@ -173,9 +193,11 @@
</select>
<select sql-case-id="select_group_by_with_order_by_and_limit" parameters="5">
<tables>
<simple-table name="t_order" start-index="49" stop-index="55" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="49" stop-index="55" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="42">
<column-projection name="user_id" start-index="7" stop-index="13" />
<aggregation-projection type="SUM" inner-expression-start-index="19" alias="orders_sum" start-index="16" stop-index="28" />
......@@ -192,9 +214,11 @@
</select>
<select sql-case-id="select_with_item_alias_match_order_by_and_group_by_items">
<tables>
<simple-table name="t_order" alias="o" start-index="26" stop-index="32" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="26" stop-index="32" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="19">
<column-projection name="user_id" alias="uid" start-index="7" stop-index="15">
<owner name="o" start-index="7" stop-index="7" />
......@@ -213,9 +237,11 @@
</select>
<select sql-case-id="select_group_by_with_date_function" parameters="1000, 1100">
<tables>
<simple-table name="t_order_item" start-delimiter="`" end-delimiter="`" start-index="91" stop-index="104" />
</tables>
<table-reference>
<table-factor>
<table name="t_order_item" start-delimiter="`" end-delimiter="`" start-index="91" stop-index="104" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="84">
<expression-projection alias="creation_date" start-index="7" stop-index="45" />
<aggregation-projection type="COUNT" inner-expression-start-index="70" alias="c_number" start-index="65" stop-index="72" />
......@@ -239,9 +265,11 @@
</select>
<select sql-case-id="select_group_by_with_keyword_alias">
<tables>
<simple-table name="t_order" start-index="58" stop-index="64" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="58" stop-index="64" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="51">
<aggregation-projection type="SUM" inner-expression-start-index="10" alias="orders_sum" start-index="7" stop-index="19" />
<column-projection name="user_id" alias="key" start-index="36" stop-index="42" />
......@@ -252,9 +280,11 @@
</select>
<select sql-case-id="select_group_by_with_count_without_column_name">
<tables>
<simple-table name="t_order" start-index="53" stop-index="59" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="53" stop-index="59" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="46">
<aggregation-projection inner-expression-start-index="12" type="COUNT" alias="orders_count" start-index="7" stop-index="21" />
<column-projection name="user_id" start-index="40" stop-index="46" />
......
......@@ -18,10 +18,16 @@
<sql-parser-test-cases>
<select sql-case-id="select_inner_join_related_with_alias" parameters="1000">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="37" stop-index="48" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="37" stop-index="48" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -44,10 +50,16 @@
</select>
<select sql-case-id="select_inner_join_related_with_name" parameters="1000">
<tables>
<simple-table name="t_order" start-index="27" stop-index="33" />
<simple-table name="t_order_item" start-index="40" stop-index="51" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="27" stop-index="33" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" start-index="40" stop-index="51" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="20">
<shorthand-projection start-index="7" stop-index="20">
<owner name="t_order_item" start-index="7" stop-index="18" />
......@@ -70,10 +82,16 @@
</select>
<select sql-case-id="select_join_using" parameters="1000">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......
......@@ -18,9 +18,11 @@
<sql-parser-test-cases>
<select sql-case-id="select_or_with_same_sharding_columns" parameters="1, 2">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -49,9 +51,11 @@
</select>
<select sql-case-id="select_or_with_different_sharding_columns" parameters="1, 2">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -80,9 +84,11 @@
</select>
<select sql-case-id="select_or_with_none_sharding_columns" parameters="1, 'init'">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -111,9 +117,11 @@
</select>
<select sql-case-id="select_or_mix_and_for_simple_pattern" parameters="1, 'init', 3">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -158,9 +166,11 @@
</select>
<select sql-case-id="select_or_mix_and_for_complex_pattern" parameters="'init', 1, 2, 3, 4">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -273,10 +283,16 @@
</select>
<select sql-case-id="select_or_mix_and_with_binding_tables" parameters="1, 2, 3">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -331,11 +347,21 @@
</select>
<select sql-case-id="select_or_mix_and_with_binding_and_broadcast_tables" parameters="1, 2, 3, 'init'">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
<simple-table name="t_broadcast_table" alias="c" start-index="104" stop-index="120" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
<join-table>
<table-factor>
<table name="t_broadcast_table" alias="c" start-index="104" stop-index="120" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......
......@@ -18,9 +18,11 @@
<sql-parser-test-cases>
<select sql-case-id="select_order_by_asc_and_index_desc">
<tables>
<simple-table name="t_order" alias="o" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -33,10 +35,16 @@
</select>
<select sql-case-id="select_order_by_desc_and_index_asc">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="27" stop-index="38" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
</table-reference>
<table-reference>
<table-factor>
<table name="t_order_item" alias="i" start-index="27" stop-index="38" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -74,9 +82,11 @@
</select>
<select sql-case-id="select_order_by_with_ordered_column">
<tables>
<simple-table name="t_order" alias="o" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<column-projection name="order_id" alias="gen_order_id_" start-index="7" stop-index="16">
<owner name="o" start-index="7" stop-index="7" />
......@@ -90,10 +100,16 @@
</select>
<select sql-case-id="select_order_by_with_date">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="27" stop-index="38" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
</table-reference>
<table-reference>
<table-factor>
<table name="t_order_item" alias="i" start-index="27" stop-index="38" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -136,9 +152,11 @@
<!-- //TODO add order-by-null-type -->
<select sql-case-id="select_order_by_for_nulls_first">
<tables>
<simple-table name="t_order" alias="o" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<column-projection name="order_id" alias="gen_order_id_" start-index="7" stop-index="16">
<owner name="o" start-index="7" stop-index="7" />
......@@ -153,9 +171,11 @@
<!-- //TODO add order-by-null-type -->
<select sql-case-id="select_order_by_for_nulls_last">
<tables>
<simple-table name="t_order" alias="o" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<column-projection name="order_id" alias="gen_order_id_" start-index="7" stop-index="16">
<owner name="o" start-index="7" stop-index="7" />
......@@ -169,9 +189,11 @@
</select>
<select sql-case-id="select_order_by_with_multiple_stars">
<tables>
<simple-table name="t_order" alias="o" start-index="29" stop-index="35" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="29" stop-index="35" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="22">
<shorthand-projection start-index="7" stop-index="7" />
<shorthand-projection start-index="20" stop-index="22">
......@@ -187,9 +209,11 @@
</select>
<select sql-case-id="select_order_by_with_alias_star_alias_name">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="o" start-index="7" stop-index="7" />
......@@ -203,9 +227,11 @@
</select>
<select sql-case-id="select_order_by_with_star_table_alias">
<tables>
<simple-table name="t_order" alias="o" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -220,9 +246,11 @@
<!--</select>-->
<select sql-case-id="select_order_by_with_table_star_table_name">
<tables>
<simple-table name="t_order" start-index="22" stop-index="28" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="22" stop-index="28" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="15">
<shorthand-projection start-index="7" stop-index="15">
<owner name="t_order" start-index="7" stop-index="13" />
......@@ -236,9 +264,11 @@
</select>
<select sql-case-id="select_order_by_with_star_no_table_alias">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -248,10 +278,16 @@
</select>
<select sql-case-id="select_order_by_with_table_star_without_table_name">
<tables>
<simple-table name="t_order" alias="o" start-index="21" stop-index="27" />
<simple-table name="t_order_item" alias="i" start-index="36" stop-index="47" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="21" stop-index="27" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="36" stop-index="47" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="14">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......
......@@ -18,10 +18,16 @@
<sql-parser-test-cases>
<select sql-case-id="select_pagination_with_group_by_and_order_by" parameters="1, 2, 9, 10, 5, 3">
<tables>
<simple-table name="t_order" alias="o" start-index="22" stop-index="28" />
<simple-table name="t_order_item" alias="i" start-index="37" stop-index="48" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="22" stop-index="28" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="37" stop-index="48" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="15">
<column-projection name="user_id" start-index="7" stop-index="15">
<owner name="i" start-index="7" stop-index="7" />
......@@ -70,10 +76,16 @@
</select>
<select sql-case-id="select_pagination_with_diff_group_by_and_order_by" parameters="1, 2, 9, 10, 5, 3">
<tables>
<simple-table name="t_order" alias="o" start-index="22" stop-index="28" />
<simple-table name="t_order_item" alias="i" start-index="37" stop-index="48" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="22" stop-index="28" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="37" stop-index="48" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="15">
<column-projection name="user_id" start-index="7" stop-index="15">
<owner name="i" start-index="7" stop-index="7" />
......
......@@ -18,10 +18,16 @@
<sql-parser-test-cases>
<select sql-case-id="select_pagination_with_offset" parameters="1, 2, 9, 10, 5">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -65,10 +71,17 @@
</select>
<select sql-case-id="select_pagination_with_row_count" parameters="1, 2, 9, 10, 5">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -111,10 +124,16 @@
</select>
<select sql-case-id="select_pagination_with_limit_with_back_quotes" parameters="1, 2, 9, 10, 5, 3">
<tables>
<simple-table name="t_order" alias="o" start-delimiter="`" end-delimiter="`" start-index="16" stop-index="24" />
<simple-table name="t_order_item" alias="i" start-delimiter="`" end-delimiter="`" start-index="33" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-delimiter="`" end-delimiter="`" start-index="16" stop-index="24" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-delimiter="`" end-delimiter="`" start-index="33" stop-index="46" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -158,10 +177,16 @@
</select>
<select sql-case-id="select_pagination_with_limit_and_offset_keyword" parameters="1, 2, 9, 10, 3, 5">
<tables>
<simple-table name="t_order" alias="o" start-delimiter="`" end-delimiter="`" start-index="16" stop-index="24" />
<simple-table name="t_order_item" alias="i" start-delimiter="`" end-delimiter="`" start-index="33" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-delimiter="`" end-delimiter="`" start-index="16" stop-index="24" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-delimiter="`" end-delimiter="`" start-index="33" stop-index="46" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -261,10 +286,16 @@
</select>
<select sql-case-id="select_pagination_with_offset_and_limit" parameters="1, 2, 9, 10, 5, 3">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -309,10 +340,16 @@
</select>
<select sql-case-id="select_pagination_with_offset_and_limit_all" parameters="1, 2, 9, 10, 5">
<tables>
<simple-table name="t_order" alias="o" start-index="16" stop-index="22" />
<simple-table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" alias="o" start-index="16" stop-index="22" />
</table-factor>
<join-table>
<table-factor>
<table name="t_order_item" alias="i" start-index="31" stop-index="42" />
</table-factor>
</join-table>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9">
<owner name="i" start-index="7" stop-index="7" />
......@@ -574,9 +611,11 @@
</select>
<select sql-case-id="select_pagination_with_row_number_not_at_end" parameters="20">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......
......@@ -18,9 +18,11 @@
<sql-parser-test-cases>
<select sql-case-id="select_sub_query_with_project">
<tables>
<simple-table name="t_order" start-index="40" stop-index="46" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="40" stop-index="46" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="33">
<column-projection name="order_id" start-index="7" stop-index="14" />
<subquery-projection start-index="17" stop-index="26" alias="num">
......@@ -61,6 +63,11 @@
</select>
</subquery-table>
</tables>
<table-reference>
<table-factor>
<subquery></subquery>
</table-factor>
</table-reference>
<projections start-index="7" stop-index="9">
<shorthand-projection start-index="7" stop-index="9" >
<owner name="t" start-index="7" stop-index="7" />
......@@ -69,9 +76,11 @@
</select>
<select sql-case-id="select_with_equal_subquery">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -83,9 +92,11 @@
<compare-right-value>
<subquery-expression start-index="38" stop-index="85" literal-start-index="38" literal-stop-index="85">
<select>
<tables>
<simple-table name="t_order_item" start-index="59" stop-index="70" />
</tables>
<table-reference>
<table-factor>
<table name="t_order_item" start-index="59" stop-index="70" />
</table-factor>
</table-reference>
<projections start-index="46" stop-index="52">
<column-projection name="user_id" start-index="46" stop-index="52" />
</projections>
......@@ -109,9 +120,11 @@
</select>
<select sql-case-id="select_with_in_subquery">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -122,9 +135,11 @@
<in-right-value>
<subquery-expression start-index="39" stop-index="93" literal-start-index="39" literal-stop-index="93">
<select>
<tables>
<simple-table name="t_order_item" start-index="60" stop-index="71" />
</tables>
<table-reference>
<table-factor>
<table name="t_order_item" start-index="60" stop-index="71" />
</table-factor>
</table-reference>
<projections start-index="47" stop-index="53">
<column-projection name="user_id" start-index="47" stop-index="53" />
</projections>
......@@ -148,9 +163,11 @@
</select>
<select sql-case-id="select_with_between_subquery" parameters="12">
<tables>
<simple-table name="t_order" start-index="14" stop-index="20" />
</tables>
<table-reference>
<table-factor>
<table name="t_order" start-index="14" stop-index="20" />
</table-factor>
</table-reference>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
......@@ -161,9 +178,11 @@
<between-right-value>
<between-subquery-expression start-index="44" stop-index="97" literal-start-index="44" literal-stop-index="97" >
<select>
<tables>
<simple-table name="t_order_item" start-index="65" stop-index="76" />
</tables>
<table-reference>
<table-factor>
<table name="t_order_item" start-index="65" stop-index="76" />
</table-factor>
</table-reference>
<projections start-index="52" stop-index="58">
<column-projection name="user_id" start-index="52" stop-index="58" />
</projections>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册