public override void ExecuteCmdlet()
        {
            this.Language = LanguageType.Parse(this.Language);
            if (this.IsParameterBound(c => c.SessionObject))
            {
                this.WorkspaceName = this.SessionObject.WorkspaceName;
                this.SparkPoolName = this.SessionObject.SparkPoolName;
                this.SessionId     = this.IsParameterBound(c => c.SessionId) ? this.SessionId : this.SessionObject.Id.Value;
                this.Language      = this.IsParameterBound(c => c.Language) ? this.Language : this.SessionObject.Language;
            }

            if (this.IsParameterBound(c => c.FilePath))
            {
                this.Code = this.ReadFileAsText(this.FilePath);
            }

            var livyRequest = new LivyStatementRequestBody
            {
                Kind = this.Language,
                Code = this.Code
            };

            var sessionStmt   = SynapseAnalyticsClient.SubmitSparkSessionStatement(this.WorkspaceName, this.SparkPoolName, this.SessionId, livyRequest, waitForCompletion: true);
            var psSessionStmt = new PSSynapseExtendedSparkStatement(sessionStmt);

            WriteObject(psSessionStmt);
        }
 /// <summary>
 /// Create statement within a spark session.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace to execute operations on.
 /// </param>
 /// <param name='sparkPoolName'>
 /// Name of the spark pool. "ondemand" targets the ondemand pool.
 /// </param>
 /// <param name='sessionId'>
 /// Identifier for the session.
 /// </param>
 /// <param name='livyRequest'>
 /// Livy compatible batch job request payload.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <LivyStatementResponseBody> CreateStatementAsync(this ISparkSessionOperations operations, string workspaceName, string sparkPoolName, int sessionId, LivyStatementRequestBody livyRequest, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateStatementWithHttpMessagesAsync(workspaceName, sparkPoolName, sessionId, livyRequest, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create statement within a spark session.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace to execute operations on.
 /// </param>
 /// <param name='sparkPoolName'>
 /// Name of the spark pool. "ondemand" targets the ondemand pool.
 /// </param>
 /// <param name='sessionId'>
 /// Identifier for the session.
 /// </param>
 /// <param name='livyRequest'>
 /// Livy compatible batch job request payload.
 /// </param>
 public static LivyStatementResponseBody CreateStatement(this ISparkSessionOperations operations, string workspaceName, string sparkPoolName, int sessionId, LivyStatementRequestBody livyRequest)
 {
     return(operations.CreateStatementAsync(workspaceName, sparkPoolName, sessionId, livyRequest).GetAwaiter().GetResult());
 }
Exemple #4
0
        public LivyStatementResponseBody SubmitSparkSessionStatement(string workspaceName, string sparkPoolName, int sessionId, LivyStatementRequestBody livyRequest, bool waitForCompletion)
        {
            var statement = _synapseClient.SparkSession.CreateStatement(workspaceName, sparkPoolName, sessionId, livyRequest);

            if (!waitForCompletion)
            {
                return(statement);
            }

            return(PollSparkSessionStatement(workspaceName, sparkPoolName, sessionId, statement));
        }