Tabnine Logo
QueryUtil.values
Code IndexAdd Tabnine to your IDE (free)

How to use
values
method
in
io.prestosql.sql.QueryUtil

Best Java code snippets using io.prestosql.sql.QueryUtil.values (Showing top 11 results out of 315)

origin: io.prestosql/presto-parser

public static Query singleValueQuery(String columnName, boolean value)
{
  Relation values = values(row(value ? TRUE_LITERAL : FALSE_LITERAL));
  return simpleQuery(
      selectList(new AllColumns()),
      aliased(values, "t", ImmutableList.of(columnName)));
}
origin: prestosql/presto

public static Query singleValueQuery(String columnName, boolean value)
{
  Relation values = values(row(value ? TRUE_LITERAL : FALSE_LITERAL));
  return simpleQuery(
      selectList(new AllColumns()),
      aliased(values, "t", ImmutableList.of(columnName)));
}
origin: io.prestosql/presto-parser

public static Query singleValueQuery(String columnName, String value)
{
  Relation values = values(row(new StringLiteral((value))));
  return simpleQuery(
      selectList(new AllColumns()),
      aliased(values, "t", ImmutableList.of(columnName)));
}
origin: prestosql/presto

public static Query singleValueQuery(String columnName, String value)
{
  Relation values = values(row(new StringLiteral((value))));
  return simpleQuery(
      selectList(new AllColumns()),
      aliased(values, "t", ImmutableList.of(columnName)));
}
origin: io.prestosql/presto-main

@Override
protected Node visitDescribeInput(DescribeInput node, Void context)
    throws SemanticException
{
  String sqlString = session.getPreparedStatement(node.getName().getValue());
  Statement statement = parser.createStatement(sqlString, createParsingOptions(session));
  // create  analysis for the query we are describing.
  Analyzer analyzer = new Analyzer(session, metadata, parser, accessControl, queryExplainer, parameters, warningCollector);
  Analysis analysis = analyzer.analyze(statement, true);
  // get all parameters in query
  List<Parameter> parameters = getParameters(statement);
  // return the positions and types of all parameters
  Row[] rows = parameters.stream().map(parameter -> createDescribeInputRow(parameter, analysis)).toArray(Row[]::new);
  Optional<String> limit = Optional.empty();
  if (rows.length == 0) {
    rows = new Row[] {row(new NullLiteral(), new NullLiteral())};
    limit = Optional.of("0");
  }
  return simpleQuery(
      selectList(identifier("Position"), identifier("Type")),
      aliased(
          values(rows),
          "Parameter Input",
          ImmutableList.of("Position", "Type")),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.of(ordering(ascending("Position"))),
      limit);
}
origin: prestosql/presto

@Override
protected Node visitDescribeInput(DescribeInput node, Void context)
    throws SemanticException
{
  String sqlString = session.getPreparedStatement(node.getName().getValue());
  Statement statement = parser.createStatement(sqlString, createParsingOptions(session));
  // create  analysis for the query we are describing.
  Analyzer analyzer = new Analyzer(session, metadata, parser, accessControl, queryExplainer, parameters, warningCollector);
  Analysis analysis = analyzer.analyze(statement, true);
  // get all parameters in query
  List<Parameter> parameters = getParameters(statement);
  // return the positions and types of all parameters
  Row[] rows = parameters.stream().map(parameter -> createDescribeInputRow(parameter, analysis)).toArray(Row[]::new);
  Optional<String> limit = Optional.empty();
  if (rows.length == 0) {
    rows = new Row[] {row(new NullLiteral(), new NullLiteral())};
    limit = Optional.of("0");
  }
  return simpleQuery(
      selectList(identifier("Position"), identifier("Type")),
      aliased(
          values(rows),
          "Parameter Input",
          ImmutableList.of("Position", "Type")),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.of(ordering(ascending("Position"))),
      limit);
}
origin: io.prestosql/presto-main

    identifier("Aliased")),
aliased(
    values(rows),
    "Statement Output",
    ImmutableList.of("Column Name", "Catalog", "Schema", "Table", "Type", "Type Size", "Aliased")),
origin: prestosql/presto

    identifier("Aliased")),
aliased(
    values(rows),
    "Statement Output",
    ImmutableList.of("Column Name", "Catalog", "Schema", "Table", "Type", "Type Size", "Aliased")),
origin: prestosql/presto

@Test
public void testLimitAll()
{
  Query valuesQuery = query(values(
      row(new LongLiteral("1"), new StringLiteral("1")),
      row(new LongLiteral("2"), new StringLiteral("2"))));
  assertStatement("SELECT * FROM (VALUES (1, '1'), (2, '2')) LIMIT ALL",
      simpleQuery(selectList(new AllColumns()),
          subquery(valuesQuery),
          Optional.empty(),
          Optional.empty(),
          Optional.empty(),
          Optional.empty(),
          Optional.of("ALL")));
}
origin: prestosql/presto

@Test
public void testValues()
{
  Query valuesQuery = query(values(
      row(new StringLiteral("a"), new LongLiteral("1"), new DoubleLiteral("2.2")),
      row(new StringLiteral("b"), new LongLiteral("2"), new DoubleLiteral("3.3"))));
  assertStatement("VALUES ('a', 1, 2.2e0), ('b', 2, 3.3e0)", valuesQuery);
  assertStatement("SELECT * FROM (VALUES ('a', 1, 2.2e0), ('b', 2, 3.3e0))",
      simpleQuery(
          selectList(new AllColumns()),
          subquery(valuesQuery)));
}
origin: prestosql/presto

@Test
public void testQuantifiedComparison()
{
  assertExpression("col1 < ANY (SELECT col2 FROM table1)",
      new QuantifiedComparisonExpression(
          LESS_THAN,
          QuantifiedComparisonExpression.Quantifier.ANY,
          identifier("col1"),
          new SubqueryExpression(simpleQuery(selectList(new SingleColumn(identifier("col2"))), table(QualifiedName.of("table1"))))));
  assertExpression("col1 = ALL (VALUES ROW(1), ROW(2))",
      new QuantifiedComparisonExpression(
          ComparisonExpression.Operator.EQUAL,
          QuantifiedComparisonExpression.Quantifier.ALL,
          identifier("col1"),
          new SubqueryExpression(query(values(row(new LongLiteral("1")), row(new LongLiteral("2")))))));
  assertExpression("col1 >= SOME (SELECT 10)",
      new QuantifiedComparisonExpression(
          ComparisonExpression.Operator.GREATER_THAN_OR_EQUAL,
          QuantifiedComparisonExpression.Quantifier.SOME,
          identifier("col1"),
          new SubqueryExpression(simpleQuery(selectList(new LongLiteral("10"))))));
}
io.prestosql.sqlQueryUtilvalues

Popular methods of QueryUtil

  • identifier
  • selectList
  • simpleQuery
  • row
  • table
  • aliased
  • query
  • aliasedName
  • aliasedNullToEmpty
  • ascending
  • equal
  • functionCall
  • equal,
  • functionCall,
  • logicalAnd,
  • ordering,
  • quotedIdentifier,
  • selectAll,
  • singleValueQuery,
  • subquery

Popular in Java

  • Making http post requests using okhttp
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • findViewById (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • JTable (javax.swing)
  • Best plugins for Eclipse
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