-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
bp #31662 Co-authored-by: slothever <[email protected]>
- Loading branch information
1 parent
4732aae
commit 1645f2e
Showing
16 changed files
with
617 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...pache/doris/nereids/rules/implementation/LogicalHiveTableSinkToPhysicalHiveTableSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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.doris.nereids.rules.implementation; | ||
|
||
import org.apache.doris.nereids.rules.Rule; | ||
import org.apache.doris.nereids.rules.RuleType; | ||
import org.apache.doris.nereids.trees.plans.Plan; | ||
import org.apache.doris.nereids.trees.plans.logical.LogicalHiveTableSink; | ||
import org.apache.doris.nereids.trees.plans.physical.PhysicalHiveTableSink; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Implementation rule that convert logical HiveTableSink to physical HiveTableSink. | ||
*/ | ||
public class LogicalHiveTableSinkToPhysicalHiveTableSink extends OneImplementationRuleFactory { | ||
@Override | ||
public Rule build() { | ||
return logicalHiveTableSink().thenApply(ctx -> { | ||
LogicalHiveTableSink<? extends Plan> sink = ctx.root; | ||
return new PhysicalHiveTableSink<>( | ||
sink.getDatabase(), | ||
sink.getTargetTable(), | ||
sink.getCols(), | ||
sink.getPartitionIds(), | ||
sink.getOutputExprs(), | ||
Optional.empty(), | ||
sink.getLogicalProperties(), | ||
null, | ||
null, | ||
sink.child()); | ||
}).toRule(RuleType.LOGICAL_HIVE_TABLE_SINK_TO_PHYSICAL_HIVE_TABLE_SINK_RULE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...rc/main/java/org/apache/doris/nereids/trees/plans/commands/insert/HiveInsertExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// 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.doris.nereids.trees.plans.commands.insert; | ||
|
||
import org.apache.doris.analysis.Analyzer; | ||
import org.apache.doris.catalog.Env; | ||
import org.apache.doris.common.UserException; | ||
import org.apache.doris.datasource.hive.HMSExternalTable; | ||
import org.apache.doris.nereids.NereidsPlanner; | ||
import org.apache.doris.nereids.exceptions.AnalysisException; | ||
import org.apache.doris.nereids.trees.plans.physical.PhysicalSink; | ||
import org.apache.doris.planner.DataSink; | ||
import org.apache.doris.planner.HiveTableSink; | ||
import org.apache.doris.planner.PlanFragment; | ||
import org.apache.doris.qe.ConnectContext; | ||
import org.apache.doris.qe.StmtExecutor; | ||
import org.apache.doris.transaction.TransactionState; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Insert executor for olap table | ||
*/ | ||
public class HiveInsertExecutor extends AbstractInsertExecutor { | ||
private static final Logger LOG = LogManager.getLogger(HiveInsertExecutor.class); | ||
private static final long INVALID_TXN_ID = -1L; | ||
private long txnId = INVALID_TXN_ID; | ||
|
||
/** | ||
* constructor | ||
*/ | ||
public HiveInsertExecutor(ConnectContext ctx, HMSExternalTable table, | ||
String labelName, NereidsPlanner planner, | ||
Optional<InsertCommandContext> insertCtx) { | ||
super(ctx, table, labelName, planner, insertCtx); | ||
} | ||
|
||
public long getTxnId() { | ||
return txnId; | ||
} | ||
|
||
@Override | ||
public void beginTransaction() { | ||
|
||
} | ||
|
||
@Override | ||
protected void finalizeSink(PlanFragment fragment, DataSink sink, PhysicalSink physicalSink) { | ||
HiveTableSink hiveTableSink = (HiveTableSink) sink; | ||
// PhysicalHiveTableSink physicalHiveTableSink = (PhysicalHiveTableSink) physicalSink; | ||
try { | ||
hiveTableSink.init(); | ||
hiveTableSink.complete(new Analyzer(Env.getCurrentEnv(), ctx)); | ||
TransactionState state = Env.getCurrentGlobalTransactionMgr().getTransactionState(database.getId(), txnId); | ||
if (state == null) { | ||
throw new AnalysisException("txn does not exist: " + txnId); | ||
} | ||
} catch (Exception e) { | ||
throw new AnalysisException(e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
protected void beforeExec() { | ||
|
||
} | ||
|
||
@Override | ||
protected void onComplete() throws UserException { | ||
|
||
} | ||
|
||
@Override | ||
protected void onFail(Throwable t) { | ||
|
||
} | ||
|
||
@Override | ||
protected void afterExec(StmtExecutor executor) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.