Loading sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/extractor/impl/common/expression/CommonExpressionExtractor.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * 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.core.parse.antlr.extractor.impl.common.expression; import com.google.common.base.Optional; import org.antlr.v4.runtime.ParserRuleContext; import org.apache.shardingsphere.core.parse.antlr.extractor.api.OptionalSQLSegmentExtractor; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.CommonExpressionSegment; import java.util.Map; /** * Common expression extractor. * * @author zhangliang */ public final class CommonExpressionExtractor implements OptionalSQLSegmentExtractor { // TODO extract column name and value from expression @Override public Optional<CommonExpressionSegment> extract(final ParserRuleContext expressionNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) { return Optional.of(new CommonExpressionSegment(expressionNode.getStart().getStartIndex(), expressionNode.getStop().getStopIndex())); } } sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/extractor/impl/common/expression/ExpressionExtractor.java +3 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import org.apache.shardingsphere.core.parse.antlr.extractor.api.OptionalSQLSegme import org.apache.shardingsphere.core.parse.antlr.extractor.impl.dml.select.SubqueryExtractor; import org.apache.shardingsphere.core.parse.antlr.extractor.util.ExtractorUtils; import org.apache.shardingsphere.core.parse.antlr.extractor.util.RuleName; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.CommonExpressionSegment; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.ExpressionSegment; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.LiteralExpressionSegment; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.ParameterMarkerExpressionSegment; Loading @@ -41,6 +40,8 @@ public final class ExpressionExtractor implements OptionalSQLSegmentExtractor { private final LiteralExpressionExtractor literalExpressionExtractor = new LiteralExpressionExtractor(); private final CommonExpressionExtractor commonExpressionExtractor = new CommonExpressionExtractor(); @Override public Optional<? extends ExpressionSegment> extract(final ParserRuleContext expressionNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) { Optional<ParserRuleContext> subqueryNode = ExtractorUtils.findFirstChildNode(expressionNode, RuleName.SUBQUERY); Loading @@ -55,7 +56,6 @@ public final class ExpressionExtractor implements OptionalSQLSegmentExtractor { if (literalExpressionSegment.isPresent()) { return literalExpressionSegment; } // TODO extract column name and value from expression return Optional.of(new CommonExpressionSegment(expressionNode.getStart().getStartIndex(), expressionNode.getStop().getStopIndex())); return commonExpressionExtractor.extract(expressionNode, parameterMarkerIndexes); } } Loading
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/extractor/impl/common/expression/CommonExpressionExtractor.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * 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.core.parse.antlr.extractor.impl.common.expression; import com.google.common.base.Optional; import org.antlr.v4.runtime.ParserRuleContext; import org.apache.shardingsphere.core.parse.antlr.extractor.api.OptionalSQLSegmentExtractor; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.CommonExpressionSegment; import java.util.Map; /** * Common expression extractor. * * @author zhangliang */ public final class CommonExpressionExtractor implements OptionalSQLSegmentExtractor { // TODO extract column name and value from expression @Override public Optional<CommonExpressionSegment> extract(final ParserRuleContext expressionNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) { return Optional.of(new CommonExpressionSegment(expressionNode.getStart().getStartIndex(), expressionNode.getStop().getStopIndex())); } }
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/extractor/impl/common/expression/ExpressionExtractor.java +3 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import org.apache.shardingsphere.core.parse.antlr.extractor.api.OptionalSQLSegme import org.apache.shardingsphere.core.parse.antlr.extractor.impl.dml.select.SubqueryExtractor; import org.apache.shardingsphere.core.parse.antlr.extractor.util.ExtractorUtils; import org.apache.shardingsphere.core.parse.antlr.extractor.util.RuleName; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.CommonExpressionSegment; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.ExpressionSegment; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.LiteralExpressionSegment; import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.ParameterMarkerExpressionSegment; Loading @@ -41,6 +40,8 @@ public final class ExpressionExtractor implements OptionalSQLSegmentExtractor { private final LiteralExpressionExtractor literalExpressionExtractor = new LiteralExpressionExtractor(); private final CommonExpressionExtractor commonExpressionExtractor = new CommonExpressionExtractor(); @Override public Optional<? extends ExpressionSegment> extract(final ParserRuleContext expressionNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) { Optional<ParserRuleContext> subqueryNode = ExtractorUtils.findFirstChildNode(expressionNode, RuleName.SUBQUERY); Loading @@ -55,7 +56,6 @@ public final class ExpressionExtractor implements OptionalSQLSegmentExtractor { if (literalExpressionSegment.isPresent()) { return literalExpressionSegment; } // TODO extract column name and value from expression return Optional.of(new CommonExpressionSegment(expressionNode.getStart().getStartIndex(), expressionNode.getStop().getStopIndex())); return commonExpressionExtractor.extract(expressionNode, parameterMarkerIndexes); } }