Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
salyh committed Jun 13, 2024
1 parent 998363d commit 4e711ad
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 77 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/org/opensearch/sql/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.opensearch.sql.ast.tree.Head;
import org.opensearch.sql.ast.tree.Kmeans;
import org.opensearch.sql.ast.tree.Limit;
import org.opensearch.sql.ast.tree.Lukk;
import org.opensearch.sql.ast.tree.Lookup;
import org.opensearch.sql.ast.tree.ML;
import org.opensearch.sql.ast.tree.Paginate;
import org.opensearch.sql.ast.tree.Parse;
Expand Down Expand Up @@ -91,7 +91,7 @@
import org.opensearch.sql.planner.logical.LogicalFetchCursor;
import org.opensearch.sql.planner.logical.LogicalFilter;
import org.opensearch.sql.planner.logical.LogicalLimit;
import org.opensearch.sql.planner.logical.LogicalLukk;
import org.opensearch.sql.planner.logical.LogicalLookup;
import org.opensearch.sql.planner.logical.LogicalML;
import org.opensearch.sql.planner.logical.LogicalMLCommons;
import org.opensearch.sql.planner.logical.LogicalPaginate;
Expand Down Expand Up @@ -510,9 +510,9 @@ public LogicalPlan visitDedupe(Dedupe node, AnalysisContext context) {
consecutive);
}

/** Build {@link LogicalLukk}. */
/** Build {@link LogicalLookup}. */
@Override
public LogicalPlan visitLukk(Lukk node, AnalysisContext context) {
public LogicalPlan visitLookup(Lookup node, AnalysisContext context) {
LogicalPlan child = node.getChild().get(0).accept(this, context);
List<Argument> options = node.getOptions();
// Todo, refactor the option.
Expand All @@ -529,15 +529,15 @@ public LogicalPlan visitLukk(Lukk node, AnalysisContext context) {
String.format("no such lookup index %s", node.getIndexName()));
}

return new LogicalLukk(
return new LogicalLookup(
child,
node.getIndexName(),
analyzeLukkMatchFields(node.getMatchFieldList(), context),
analyzeLookupMatchFields(node.getMatchFieldList(), context),
appendOnly,
analyzeLukkCopyFields(node.getCopyFieldList(), context, table));
analyzeLookupCopyFields(node.getCopyFieldList(), context, table));
}

private ImmutableMap<ReferenceExpression, ReferenceExpression> analyzeLukkMatchFields(
private ImmutableMap<ReferenceExpression, ReferenceExpression> analyzeLookupMatchFields(
List<Map> inputMap, AnalysisContext context) {
ImmutableMap.Builder<ReferenceExpression, ReferenceExpression> copyMapBuilder =
new ImmutableMap.Builder<>();
Expand All @@ -561,7 +561,7 @@ private ImmutableMap<ReferenceExpression, ReferenceExpression> analyzeLukkMatchF
return copyMapBuilder.build();
}

private ImmutableMap<ReferenceExpression, ReferenceExpression> analyzeLukkCopyFields(
private ImmutableMap<ReferenceExpression, ReferenceExpression> analyzeLookupCopyFields(
List<Map> inputMap, AnalysisContext context, Table table) {

TypeEnvironment curEnv = context.peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.opensearch.sql.ast.tree.Head;
import org.opensearch.sql.ast.tree.Kmeans;
import org.opensearch.sql.ast.tree.Limit;
import org.opensearch.sql.ast.tree.Lukk;
import org.opensearch.sql.ast.tree.Lookup;
import org.opensearch.sql.ast.tree.ML;
import org.opensearch.sql.ast.tree.Paginate;
import org.opensearch.sql.ast.tree.Parse;
Expand Down Expand Up @@ -218,7 +218,7 @@ public T visitDedupe(Dedupe node, C context) {
return visitChildren(node, context);
}

public T visitLukk(Lukk node, C context) {
public T visitLookup(Lookup node, C context) {
return visitChildren(node, context);
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.opensearch.sql.ast.tree.Filter;
import org.opensearch.sql.ast.tree.Head;
import org.opensearch.sql.ast.tree.Limit;
import org.opensearch.sql.ast.tree.Lukk;
import org.opensearch.sql.ast.tree.Lookup;
import org.opensearch.sql.ast.tree.Parse;
import org.opensearch.sql.ast.tree.Project;
import org.opensearch.sql.ast.tree.RareTopN;
Expand Down Expand Up @@ -443,13 +443,13 @@ public static Dedupe dedupe(UnresolvedPlan input, List<Argument> options, Field.
return new Dedupe(input, options, Arrays.asList(fields));
}

public static Lukk lukk(
public static Lookup lookup(
UnresolvedPlan input,
String indexName,
List<Map> matchFieldList,
List<Argument> options,
List<Map> copyFieldList) {
return new Lukk(input, indexName, matchFieldList, options, copyFieldList);
return new Lookup(input, indexName, matchFieldList, options, copyFieldList);
}

public static List<Map> fieldMap(String field, String asField, String... more) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
import org.opensearch.sql.ast.expression.Argument;
import org.opensearch.sql.ast.expression.Map;

/** AST node represent Lukk operation. */
/** AST node represent Lookup operation. */
@Getter
@Setter
@ToString
@EqualsAndHashCode(callSuper = false)
@RequiredArgsConstructor
@AllArgsConstructor
public class Lukk extends UnresolvedPlan {
public class Lookup extends UnresolvedPlan {
private UnresolvedPlan child;
private final String indexName;
private final List<Map> matchFieldList;
private final List<Argument> options;
private final List<Map> copyFieldList;

@Override
public Lukk attach(UnresolvedPlan child) {
public Lookup attach(UnresolvedPlan child) {
this.child = child;
return this;
}
Expand All @@ -44,6 +44,6 @@ public List<UnresolvedPlan> getChild() {

@Override
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
return nodeVisitor.visitLukk(this, context);
return nodeVisitor.visitLookup(this, context);
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/opensearch/sql/executor/Explain.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.opensearch.sql.planner.physical.EvalOperator;
import org.opensearch.sql.planner.physical.FilterOperator;
import org.opensearch.sql.planner.physical.LimitOperator;
import org.opensearch.sql.planner.physical.LukkOperator;
import org.opensearch.sql.planner.physical.LookupOperator;
import org.opensearch.sql.planner.physical.NestedOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.PhysicalPlanNodeVisitor;
Expand Down Expand Up @@ -159,7 +159,7 @@ public ExplainResponseNode visitDedupe(DedupeOperator node, Object context) {
}

@Override
public ExplainResponseNode visitLukk(LukkOperator node, Object context) {
public ExplainResponseNode visitLookup(LookupOperator node, Object context) {
return explain(
node,
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.opensearch.sql.planner.logical.LogicalFetchCursor;
import org.opensearch.sql.planner.logical.LogicalFilter;
import org.opensearch.sql.planner.logical.LogicalLimit;
import org.opensearch.sql.planner.logical.LogicalLukk;
import org.opensearch.sql.planner.logical.LogicalLookup;
import org.opensearch.sql.planner.logical.LogicalNested;
import org.opensearch.sql.planner.logical.LogicalPaginate;
import org.opensearch.sql.planner.logical.LogicalPlan;
Expand All @@ -32,7 +32,7 @@
import org.opensearch.sql.planner.physical.EvalOperator;
import org.opensearch.sql.planner.physical.FilterOperator;
import org.opensearch.sql.planner.physical.LimitOperator;
import org.opensearch.sql.planner.physical.LukkOperator;
import org.opensearch.sql.planner.physical.LookupOperator;
import org.opensearch.sql.planner.physical.NestedOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.ProjectOperator;
Expand Down Expand Up @@ -77,8 +77,8 @@ public PhysicalPlan visitDedupe(LogicalDedupe node, C context) {
}

@Override
public PhysicalPlan visitLukk(LogicalLukk node, C context) {
return new LukkOperator(
public PhysicalPlan visitLookup(LogicalLookup node, C context) {
return new LookupOperator(
visitChild(node, context),
node.getIndexName(),
node.getMatchFieldMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
@Getter
@ToString
@EqualsAndHashCode(callSuper = true)
public class LogicalLukk extends LogicalPlan {
public class LogicalLookup extends LogicalPlan {

private final String indexName;
private final Map<ReferenceExpression, ReferenceExpression> matchFieldMap;
private final Map<ReferenceExpression, ReferenceExpression> copyFieldMap;
private final Boolean appendOnly;

/** Constructor of LogicalDedupe. */
public LogicalLukk(
public LogicalLookup(
LogicalPlan child,
String indexName,
Map<ReferenceExpression, ReferenceExpression> matchFieldMap,
Expand All @@ -39,6 +39,6 @@ public LogicalLukk(

@Override
public <R, C> R accept(LogicalPlanNodeVisitor<R, C> visitor, C context) {
return visitor.visitLukk(this, context);
return visitor.visitLookup(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public R visitDedupe(LogicalDedupe plan, C context) {
return visitNode(plan, context);
}

public R visitLukk(LogicalLukk plan, C context) {
public R visitLookup(LogicalLookup plan, C context) {
return visitNode(plan, context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
import org.opensearch.sql.data.model.ExprValueUtils;
import org.opensearch.sql.expression.ReferenceExpression;

/** Lukk operator. Perform lookup on another OpenSearch index and enrich the results. */
/** Lookup operator. Perform lookup on another OpenSearch index and enrich the results. */
@Getter
@EqualsAndHashCode(callSuper = false)
public class LukkOperator extends PhysicalPlan {
public class LookupOperator extends PhysicalPlan {
@Getter private final PhysicalPlan input;
@Getter private final String indexName;
@Getter private final Map<ReferenceExpression, ReferenceExpression> matchFieldMap;
@Getter private final Map<ReferenceExpression, ReferenceExpression> copyFieldMap;
@Getter private final Boolean appendOnly;
private final BiFunction<String, Map<String, Object>, Map<String, Object>> lookup;

/** Lukk Constructor. */
/** Lookup Constructor. */
@NonNull
public LukkOperator(
public LookupOperator(
PhysicalPlan input,
String indexName,
Map<ReferenceExpression, ReferenceExpression> matchFieldMap,
Expand All @@ -50,7 +50,7 @@ public LukkOperator(

@Override
public <R, C> R accept(PhysicalPlanNodeVisitor<R, C> visitor, C context) {
return visitor.visitLukk(this, context);
return visitor.visitLookup(this, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public static DedupeOperator dedupe(
input, Arrays.asList(expressions), allowedDuplication, keepEmpty, consecutive);
}

public static LukkOperator lukk(
public static LookupOperator lookup(
PhysicalPlan input,
String indexName,
Map<ReferenceExpression, ReferenceExpression> matchFieldMap,
Boolean appendOnly,
Map<ReferenceExpression, ReferenceExpression> copyFieldMap) {
return new LukkOperator(
return new LookupOperator(
input,
indexName,
matchFieldMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public R visitDedupe(DedupeOperator node, C context) {
return visitNode(node, context);
}

public R visitLukk(LukkOperator node, C context) {
public R visitLookup(LookupOperator node, C context) {
return visitNode(node, context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.json.JSONObject;
import org.junit.jupiter.api.Test;

public class LukkCommandIT extends PPLIntegTestCase {
public class LookupCommandIT extends PPLIntegTestCase {

@Override
public void init() throws IOException {
Expand All @@ -23,8 +23,8 @@ public void init() throws IOException {
}

@Test
public void testLukk() throws IOException {
JSONObject result = executeQuery(String.format("source=%s | lukk %s male", TEST_INDEX_BANK));
public void testLookup() throws IOException {
JSONObject result = executeQuery(String.format("source=%s | lookup %s male", TEST_INDEX_BANK));
verifyDataRows(result, rows(true), rows(false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.opensearch.sql.planner.physical.EvalOperator;
import org.opensearch.sql.planner.physical.FilterOperator;
import org.opensearch.sql.planner.physical.LimitOperator;
import org.opensearch.sql.planner.physical.LukkOperator;
import org.opensearch.sql.planner.physical.LookupOperator;
import org.opensearch.sql.planner.physical.NestedOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.ProjectOperator;
Expand Down Expand Up @@ -135,8 +135,8 @@ public PhysicalPlan visitDedupe(DedupeOperator node, Object context) {
}

@Override
public PhysicalPlan visitLukk(LukkOperator node, Object context) {
return new LukkOperator(
public PhysicalPlan visitLookup(LookupOperator node, Object context) {
return new LookupOperator(
visitInput(node.getInput(), context),
node.getIndexName(),
node.getMatchFieldMap(),
Expand Down
1 change: 0 additions & 1 deletion ppl/src/main/antlr/OpenSearchPPLLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ NEW_FIELD: 'NEW_FIELD';
KMEANS: 'KMEANS';
AD: 'AD';
ML: 'ML';
LUKK: 'LUKK';

// COMMAND ASSIST KEYWORDS
AS: 'AS';
Expand Down
8 changes: 4 additions & 4 deletions ppl/src/main/antlr/OpenSearchPPLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ commands
| renameCommand
| statsCommand
| dedupCommand
| lukkCommand
| lookupCommand
| sortCommand
| evalCommand
| headCommand
Expand Down Expand Up @@ -94,8 +94,8 @@ copyFieldWithOptAs
: orignalCopyField = fieldExpression (AS asCopyField = fieldExpression)?
;

lukkCommand
: LUKK tableSource matchFieldWithOptAs (COMMA matchFieldWithOptAs)* (APPENDONLY EQUAL appendonly = booleanLiteral)? (copyFieldWithOptAs (COMMA copyFieldWithOptAs)*)*
lookupCommand
: LOOKUP tableSource matchFieldWithOptAs (COMMA matchFieldWithOptAs)* (APPENDONLY EQUAL appendonly = booleanLiteral)? (copyFieldWithOptAs (COMMA copyFieldWithOptAs)*)*
;

sortCommand
Expand Down Expand Up @@ -845,7 +845,7 @@ keywordsCanBeId
| RENAME
| STATS
| DEDUP
| LUKK
| LOOKUP
| SORT
| EVAL
| HEAD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.FieldsCommandContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.FromClauseContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.HeadCommandContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.LukkCommandContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.LookupCommandContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.RareCommandContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.RenameCommandContext;
import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.SearchFilterFromContext;
Expand Down Expand Up @@ -55,7 +55,7 @@
import org.opensearch.sql.ast.tree.Filter;
import org.opensearch.sql.ast.tree.Head;
import org.opensearch.sql.ast.tree.Kmeans;
import org.opensearch.sql.ast.tree.Lukk;
import org.opensearch.sql.ast.tree.Lookup;
import org.opensearch.sql.ast.tree.ML;
import org.opensearch.sql.ast.tree.Parse;
import org.opensearch.sql.ast.tree.Project;
Expand Down Expand Up @@ -216,12 +216,12 @@ public UnresolvedPlan visitDedupCommand(DedupCommandContext ctx) {

/** Lookup command */
@Override
public UnresolvedPlan visitLukkCommand(LukkCommandContext ctx) {
public UnresolvedPlan visitLookupCommand(LookupCommandContext ctx) {
ArgumentFactory.getArgumentList(ctx);
ctx.tableSource();
ctx.copyFieldWithOptAs();
ctx.matchFieldWithOptAs();
return new Lukk(
return new Lookup(
ctx.tableSource().tableQualifiedName().getText(),
ctx.matchFieldWithOptAs().stream()
.map(
Expand Down
Loading

0 comments on commit 4e711ad

Please sign in to comment.