Search in sources :

Example 11 with BetaApi

use of com.google.api.core.BetaApi in project java-bigquery by googleapis.

the class ConnectionImpl method dryRun.

/**
 * This method runs a dry run query
 *
 * @param sql SQL SELECT statement
 * @return BigQueryDryRunResult containing List<Parameter> and Schema
 * @throws BigQuerySQLException
 */
@BetaApi
@Override
public BigQueryDryRunResult dryRun(String sql) throws BigQuerySQLException {
    com.google.api.services.bigquery.model.Job dryRunJob = createDryRunJob(sql);
    Schema schema = Schema.fromPb(dryRunJob.getStatistics().getQuery().getSchema());
    List<QueryParameter> queryParametersPb = dryRunJob.getStatistics().getQuery().getUndeclaredQueryParameters();
    List<Parameter> queryParameters = Lists.transform(queryParametersPb, QUERY_PARAMETER_FROM_PB_FUNCTION);
    QueryStatistics queryStatistics = JobStatistics.fromPb(dryRunJob);
    SessionInfo sessionInfo = queryStatistics.getSessionInfo() == null ? null : queryStatistics.getSessionInfo();
    BigQueryResultStats bigQueryResultStats = new BigQueryResultStatsImpl(queryStatistics, sessionInfo);
    return new BigQueryDryRunResultImpl(schema, queryParameters, bigQueryResultStats);
}
Also used : QueryParameter(com.google.api.services.bigquery.model.QueryParameter) ArrowSchema(com.google.cloud.bigquery.storage.v1.ArrowSchema) SessionInfo(com.google.cloud.bigquery.JobStatistics.SessionInfo) QueryStatistics(com.google.cloud.bigquery.JobStatistics.QueryStatistics) QueryParameter(com.google.api.services.bigquery.model.QueryParameter) BetaApi(com.google.api.core.BetaApi)

Aggregations

BetaApi (com.google.api.core.BetaApi)11 AnnotationNode (com.google.api.generator.engine.ast.AnnotationNode)5 AssignmentExpr (com.google.api.generator.engine.ast.AssignmentExpr)5 CastExpr (com.google.api.generator.engine.ast.CastExpr)5 ClassDefinition (com.google.api.generator.engine.ast.ClassDefinition)5 CommentStatement (com.google.api.generator.engine.ast.CommentStatement)5 ConcreteReference (com.google.api.generator.engine.ast.ConcreteReference)5 Expr (com.google.api.generator.engine.ast.Expr)5 ExprStatement (com.google.api.generator.engine.ast.ExprStatement)5 MethodDefinition (com.google.api.generator.engine.ast.MethodDefinition)5 MethodInvocationExpr (com.google.api.generator.engine.ast.MethodInvocationExpr)5 NewObjectExpr (com.google.api.generator.engine.ast.NewObjectExpr)5 PrimitiveValue (com.google.api.generator.engine.ast.PrimitiveValue)5 Reference (com.google.api.generator.engine.ast.Reference)5 RelationalOperationExpr (com.google.api.generator.engine.ast.RelationalOperationExpr)5 ScopeNode (com.google.api.generator.engine.ast.ScopeNode)5 Statement (com.google.api.generator.engine.ast.Statement)5 TernaryExpr (com.google.api.generator.engine.ast.TernaryExpr)5 ThisObjectValue (com.google.api.generator.engine.ast.ThisObjectValue)5 TypeNode (com.google.api.generator.engine.ast.TypeNode)5