Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,16 @@ public List<TupleId> getTableRefIds() {
return result;
}

public List<TupleId> getAllTableRefIds() {
List<TupleId> result = Lists.newArrayList();

for (TableRef ref : fromClause) {
result.addAll(ref.getAllTableRefIds());
}

return result;
}

public List<TupleId> getTableRefIdsWithoutInlineView() {
List<TupleId> result = Lists.newArrayList();

Expand Down Expand Up @@ -876,7 +886,7 @@ public void materializeRequiredSlots(Analyzer analyzer) throws AnalysisException
// can also be safely evaluated below the join (picked up by getBoundPredicates()).
// Such predicates will be marked twice and that is ok.
List<Expr> unassigned =
analyzer.getUnassignedConjuncts(getTableRefIds(), true);
analyzer.getUnassignedConjuncts(getAllTableRefIds(), true);
List<Expr> unassignedJoinConjuncts = Lists.newArrayList();
for (Expr e : unassigned) {
if (analyzer.evalAfterJoin(e)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,12 @@ public void analyzeJoin(Analyzer analyzer) throws AnalysisException {
// Indicate that this table ref has an empty ON-clause.
analyzer.registerOnClauseConjuncts(Collections.<Expr>emptyList(), this);
}

if (lateralViewRefs != null) {
for (LateralViewRef lateralViewRef : lateralViewRefs) {
allTableRefIds.add(lateralViewRef.getId());
}
}
}

public void rewriteExprs(ExprRewriter rewriter, Analyzer analyzer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private SortInfo createSortInfo(
ExprSubstitutionMap sortSmap = new ExprSubstitutionMap();
List<Expr> sortSlotExprs = Lists.newArrayList();
sortTupleDesc.setIsMaterialized(true);
for (TupleId tid : input.getTupleIds()) {
for (TupleId tid : input.getOutputTupleIds()) {
TupleDescriptor tupleDesc = analyzer.getTupleDesc(tid);
for (SlotDescriptor inputSlotDesc : tupleDesc.getSlots()) {
if (!inputSlotDesc.isMaterialized()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public TableFunctionNode(PlanNodeId id, PlanNode inputNode, TupleId lateralViewT

protected TableFunctionNode(PlanNodeId id, PlanNode inputNode, List<LateralViewRef> lateralViewRefs) {
super(id, "TABLE FUNCTION NODE", StatisticalType.TABLE_FUNCTION_NODE);
tupleIds.addAll(inputNode.getTupleIds());
tupleIds.addAll(inputNode.getOutputTupleIds());
tblRefIds.addAll(inputNode.getTupleIds());
tblRefIds.addAll(inputNode.getTblRefIds());
lateralViewTupleIds = lateralViewRefs.stream().map(e -> e.getDesc().getId())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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.

suite("test_inlineview_with_window_function") {
sql """
drop view if exists test_table_aa;
"""

sql """
drop table if exists test_table_bb;
"""

sql """
CREATE TABLE `test_table_bb` (
`event_date` datetime NULL,
`event_content` text NULL,
`animal_id` bigint(20) NULL
) ENGINE=OLAP
DUPLICATE KEY(`event_date`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`event_date`) BUCKETS 48
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2",
"disable_auto_compaction" = "false"
);
"""

sql """
CREATE VIEW test_table_aa AS
SELECT
ev.event_date,
ev.animal_id,
get_json_int(ev.event_content, "\$.nurseOns") as nurseons
FROM test_table_bb ev;
"""

sql """
SELECT row_number() over(PARTITION BY animal_id ORDER BY event_date DESC) rw
FROM test_table_aa;
"""

sql """
select
e1
from test_table_aa
lateral view explode([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]) tmp1 as e1
where animal_id <= e1;
"""

sql """
drop view if exists test_table_aa;
"""

sql """
drop table if exists test_table_bb;
"""
}