Skip to content
Open
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 @@ -61,6 +61,7 @@
import org.opensearch.sql.ast.tree.Append;
import org.opensearch.sql.ast.tree.AppendCol;
import org.opensearch.sql.ast.tree.Bin;
import org.opensearch.sql.ast.tree.Chart;
import org.opensearch.sql.ast.tree.CloseCursor;
import org.opensearch.sql.ast.tree.Dedupe;
import org.opensearch.sql.ast.tree.Eval;
Expand Down Expand Up @@ -764,6 +765,11 @@ public LogicalPlan visitSpath(SPath node, AnalysisContext context) {
throw getOnlyForCalciteException("Spath");
}

@Override
public LogicalPlan visitChart(Chart node, AnalysisContext context) {
throw getOnlyForCalciteException("Chart");
}

@Override
public LogicalPlan visitTimechart(Timechart node, AnalysisContext context) {
throw getOnlyForCalciteException("Timechart");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.opensearch.sql.ast.tree.Append;
import org.opensearch.sql.ast.tree.AppendCol;
import org.opensearch.sql.ast.tree.Bin;
import org.opensearch.sql.ast.tree.Chart;
import org.opensearch.sql.ast.tree.CloseCursor;
import org.opensearch.sql.ast.tree.Dedupe;
import org.opensearch.sql.ast.tree.Eval;
Expand Down Expand Up @@ -274,6 +275,10 @@ public T visitReverse(Reverse node, C context) {
return visitChildren(node, context);
}

public T visitChart(Chart node, C context) {
return visitChildren(node, context);
}

public T visitTimechart(Timechart node, C context) {
return visitChildren(node, context);
}
Expand Down
55 changes: 55 additions & 0 deletions core/src/main/java/org/opensearch/sql/ast/tree/Chart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.ast.tree;

import com.google.common.collect.ImmutableList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.opensearch.sql.ast.AbstractNodeVisitor;
import org.opensearch.sql.ast.dsl.AstDSL;
import org.opensearch.sql.ast.expression.Argument;
import org.opensearch.sql.ast.expression.Literal;
import org.opensearch.sql.ast.expression.UnresolvedExpression;

/** AST node represent chart command. */
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@lombok.Builder(toBuilder = true)
public class Chart extends UnresolvedPlan {
public static final Literal DEFAULT_USE_OTHER = Literal.TRUE;
public static final Literal DEFAULT_OTHER_STR = AstDSL.stringLiteral("OTHER");
public static final Literal DEFAULT_LIMIT = AstDSL.intLiteral(10);
public static final Literal DEFAULT_USE_NULL = Literal.TRUE;
public static final Literal DEFAULT_NULL_STR = AstDSL.stringLiteral("NULL");
public static final Literal DEFAULT_TOP = Literal.TRUE;

private UnresolvedPlan child;
private UnresolvedExpression rowSplit;
private UnresolvedExpression columnSplit;
private UnresolvedExpression aggregationFunction;
private List<Argument> arguments;

@Override
public UnresolvedPlan attach(UnresolvedPlan child) {
this.child = child;
return this;
}

@Override
public List<UnresolvedPlan> getChild() {
return this.child == null ? ImmutableList.of() : ImmutableList.of(this.child);
}

@Override
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
return nodeVisitor.visitChart(this, context);
}
}
Loading
Loading