Tabnine Logo
ExplainType
Code IndexAdd Tabnine to your IDE (free)

How to use
ExplainType
in
com.facebook.presto.sql.tree

Best Java code snippets using com.facebook.presto.sql.tree.ExplainType (Showing top 20 results out of 315)

origin: prestodb/presto

@Override
public Node visitExplainType(SqlBaseParser.ExplainTypeContext context)
{
  switch (context.value.getType()) {
    case SqlBaseLexer.LOGICAL:
      return new ExplainType(getLocation(context), ExplainType.Type.LOGICAL);
    case SqlBaseLexer.DISTRIBUTED:
      return new ExplainType(getLocation(context), ExplainType.Type.DISTRIBUTED);
    case SqlBaseLexer.VALIDATE:
      return new ExplainType(getLocation(context), ExplainType.Type.VALIDATE);
    case SqlBaseLexer.IO:
      return new ExplainType(getLocation(context), ExplainType.Type.IO);
  }
  throw new IllegalArgumentException("Unsupported EXPLAIN type: " + context.value.getText());
}
origin: prestodb/presto

@Override
protected Void visitExplain(Explain node, Integer indent)
{
  builder.append("EXPLAIN ");
  if (node.isAnalyze()) {
    builder.append("ANALYZE ");
  }
  List<String> options = new ArrayList<>();
  for (ExplainOption option : node.getOptions()) {
    if (option instanceof ExplainType) {
      options.add("TYPE " + ((ExplainType) option).getType());
    }
    else if (option instanceof ExplainFormat) {
      options.add("FORMAT " + ((ExplainFormat) option).getType());
    }
    else {
      throw new UnsupportedOperationException("unhandled explain option: " + option);
    }
  }
  if (!options.isEmpty()) {
    builder.append("(");
    Joiner.on(", ").appendTo(builder, options);
    builder.append(")");
  }
  builder.append("\n");
  process(node.getStatement(), indent);
  return null;
}
origin: uk.co.nichesolutions.presto/presto-main

if (node.getOptions().stream().anyMatch(option -> !option.equals(new ExplainType(DISTRIBUTED)))) {
  throw new SemanticException(NOT_SUPPORTED, node, "EXPLAIN ANALYZE only supports TYPE DISTRIBUTED option");
  planType = ((ExplainType) option).getType();
  break;
origin: prestodb/presto

@Override
protected Scope visitExplain(Explain node, Optional<Scope> scope)
    throws SemanticException
{
  checkState(node.isAnalyze(), "Non analyze explain should be rewritten to Query");
  if (node.getOptions().stream().anyMatch(option -> !option.equals(new ExplainType(DISTRIBUTED)))) {
    throw new SemanticException(NOT_SUPPORTED, node, "EXPLAIN ANALYZE only supports TYPE DISTRIBUTED option");
  }
  process(node.getStatement(), scope);
  analysis.setUpdateType(null);
  return createAndAssignScope(node, scope, Field.newUnqualified("Query Plan", VARCHAR));
}
origin: prestodb/presto

@Override
protected Node visitExplain(Explain node, Void context)
    throws SemanticException
{
  if (node.isAnalyze()) {
    Statement statement = (Statement) process(node.getStatement(), context);
    return new Explain(statement, node.isAnalyze(), node.isVerbose(), node.getOptions());
  }
  ExplainType.Type planType = LOGICAL;
  ExplainFormat.Type planFormat = TEXT;
  List<ExplainOption> options = node.getOptions();
  for (ExplainOption option : options) {
    if (option instanceof ExplainType) {
      planType = ((ExplainType) option).getType();
      // Use JSON as the default format for EXPLAIN (TYPE IO).
      if (planType == IO) {
        planFormat = JSON;
      }
      break;
    }
  }
  for (ExplainOption option : options) {
    if (option instanceof ExplainFormat) {
      planFormat = ((ExplainFormat) option).getType();
      break;
    }
  }
  return getQueryPlan(node, planType, planFormat);
}
origin: prestodb/presto

@Test
public void testExplainVerboseTypeLogical()
{
  assertStatement("EXPLAIN VERBOSE (type LOGICAL) SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, true, ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL))));
}
origin: rakam-io/rakam

@Override
protected Void visitExplain(Explain node, Integer indent) {
  builder.append("EXPLAIN ");
  if (node.isAnalyze()) {
    builder.append("ANALYZE ");
  }
  List<String> options = new ArrayList<>();
  for (ExplainOption option : node.getOptions()) {
    if (option instanceof ExplainType) {
      options.add("TYPE " + ((ExplainType) option).getType());
    } else if (option instanceof ExplainFormat) {
      options.add("FORMAT " + ((ExplainFormat) option).getType());
    } else {
      throw new UnsupportedOperationException("unhandled explain option: " + option);
    }
  }
  if (!options.isEmpty()) {
    builder.append("(");
    Joiner.on(", ").appendTo(builder, options);
    builder.append(")");
  }
  builder.append("\n");
  process(node.getStatement(), indent);
  return null;
}
origin: prestodb/presto

@Test
public void testExplainAnalyzeTypeDistributed()
{
  assertStatement("EXPLAIN ANALYZE (type DISTRIBUTED) SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), true, false, ImmutableList.of(new ExplainType(ExplainType.Type.DISTRIBUTED))));
}
origin: vqtran/EchoQuery

@Override
protected Void visitExplain(Explain node, Integer indent)
{
  builder.append("EXPLAIN ");
  List<String> options = new ArrayList<>();
  for (ExplainOption option : node.getOptions()) {
    if (option instanceof ExplainType) {
      options.add("TYPE " + ((ExplainType) option).getType());
    }
    else if (option instanceof ExplainFormat) {
      options.add("FORMAT " + ((ExplainFormat) option).getType());
    }
    else {
      throw new UnsupportedOperationException("unhandled explain option: " + option);
    }
  }
  if (!options.isEmpty()) {
    builder.append("(");
    Joiner.on(", ").appendTo(builder, options);
    builder.append(")");
  }
  builder.append("\n");
  process(node.getStatement(), indent);
  return null;
}
origin: prestodb/presto

@Test
public void testExplainAnalyzeVerboseTypeDistributed()
{
  assertStatement("EXPLAIN ANALYZE VERBOSE (type DISTRIBUTED) SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), true, true, ImmutableList.of(new ExplainType(ExplainType.Type.DISTRIBUTED))));
}
origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected Void visitExplain(Explain node, Integer indent)
{
  builder.append("EXPLAIN ");
  if (node.isAnalyze()) {
    builder.append("ANALYZE ");
  }
  List<String> options = new ArrayList<>();
  for (ExplainOption option : node.getOptions()) {
    if (option instanceof ExplainType) {
      options.add("TYPE " + ((ExplainType) option).getType());
    }
    else if (option instanceof ExplainFormat) {
      options.add("FORMAT " + ((ExplainFormat) option).getType());
    }
    else {
      throw new UnsupportedOperationException("unhandled explain option: " + option);
    }
  }
  if (!options.isEmpty()) {
    builder.append("(");
    Joiner.on(", ").appendTo(builder, options);
    builder.append(")");
  }
  builder.append("\n");
  process(node.getStatement(), indent);
  return null;
}
origin: prestodb/presto

@Test
public void testExplain()
{
  assertStatement("EXPLAIN SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of()));
  assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t",
      new Explain(
          simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
          false,
          false,
          ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL))));
  assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t",
      new Explain(
          simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
          false,
          false,
          ImmutableList.of(
              new ExplainType(ExplainType.Type.LOGICAL),
              new ExplainFormat(ExplainFormat.Type.TEXT))));
}
origin: com.facebook.presto/presto-parser

@Override
protected Void visitExplain(Explain node, Integer indent)
{
  builder.append("EXPLAIN ");
  if (node.isAnalyze()) {
    builder.append("ANALYZE ");
  }
  List<String> options = new ArrayList<>();
  for (ExplainOption option : node.getOptions()) {
    if (option instanceof ExplainType) {
      options.add("TYPE " + ((ExplainType) option).getType());
    }
    else if (option instanceof ExplainFormat) {
      options.add("FORMAT " + ((ExplainFormat) option).getType());
    }
    else {
      throw new UnsupportedOperationException("unhandled explain option: " + option);
    }
  }
  if (!options.isEmpty()) {
    builder.append("(");
    Joiner.on(", ").appendTo(builder, options);
    builder.append(")");
  }
  builder.append("\n");
  process(node.getStatement(), indent);
  return null;
}
origin: uk.co.nichesolutions.presto/presto-parser

@Override
public Node visitExplainType(SqlBaseParser.ExplainTypeContext context)
{
  switch (context.value.getType()) {
    case SqlBaseLexer.LOGICAL:
      return new ExplainType(getLocation(context), ExplainType.Type.LOGICAL);
    case SqlBaseLexer.DISTRIBUTED:
      return new ExplainType(getLocation(context), ExplainType.Type.DISTRIBUTED);
  }
  throw new IllegalArgumentException("Unsupported EXPLAIN type: " + context.value.getText());
}
origin: com.facebook.presto/presto-parser

@Override
public Node visitExplainType(SqlBaseParser.ExplainTypeContext context)
{
  switch (context.value.getType()) {
    case SqlBaseLexer.LOGICAL:
      return new ExplainType(getLocation(context), ExplainType.Type.LOGICAL);
    case SqlBaseLexer.DISTRIBUTED:
      return new ExplainType(getLocation(context), ExplainType.Type.DISTRIBUTED);
    case SqlBaseLexer.VALIDATE:
      return new ExplainType(getLocation(context), ExplainType.Type.VALIDATE);
    case SqlBaseLexer.IO:
      return new ExplainType(getLocation(context), ExplainType.Type.IO);
  }
  throw new IllegalArgumentException("Unsupported EXPLAIN type: " + context.value.getText());
}
origin: com.facebook.presto/presto-parser

@Test
public void testExplainAnalyzeVerboseTypeDistributed()
{
  assertStatement("EXPLAIN ANALYZE VERBOSE (type DISTRIBUTED) SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), true, true, ImmutableList.of(new ExplainType(ExplainType.Type.DISTRIBUTED))));
}
origin: com.facebook.presto/presto-parser

@Test
public void testExplainVerboseTypeLogical()
{
  assertStatement("EXPLAIN VERBOSE (type LOGICAL) SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, true, ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL))));
}
origin: com.facebook.presto/presto-parser

@Test
public void testExplainAnalyzeTypeDistributed()
{
  assertStatement("EXPLAIN ANALYZE (type DISTRIBUTED) SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), true, false, ImmutableList.of(new ExplainType(ExplainType.Type.DISTRIBUTED))));
}
origin: uk.co.nichesolutions.presto/presto-parser

@Test
public void testExplain()
    throws Exception
{
  assertStatement("EXPLAIN SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, ImmutableList.of()));
  assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t",
      new Explain(
          simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
          false,
          ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL))));
  assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t",
      new Explain(
          simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
          false,
          ImmutableList.of(
              new ExplainType(ExplainType.Type.LOGICAL),
              new ExplainFormat(ExplainFormat.Type.TEXT))));
}
origin: com.facebook.presto/presto-parser

@Test
public void testExplain()
{
  assertStatement("EXPLAIN SELECT * FROM t",
      new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of()));
  assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t",
      new Explain(
          simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
          false,
          false,
          ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL))));
  assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t",
      new Explain(
          simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
          false,
          false,
          ImmutableList.of(
              new ExplainType(ExplainType.Type.LOGICAL),
              new ExplainFormat(ExplainFormat.Type.TEXT))));
}
com.facebook.presto.sql.treeExplainType

Most used methods

  • <init>
  • getType

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • compareTo (BigDecimal)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now