internal SparkStatement(int id, string code, string state, SparkStatementOutput output)
 {
     Id     = id;
     Code   = code;
     State  = state;
     Output = output;
 }
Ejemplo n.º 2
0
 public PSLivyStatementOutput(SparkStatementOutput output)
 {
     this.Status         = output?.Status;
     this.ExecutionCount = output?.ExecutionCount;
     //this.Data = LivyStatementOutputParser.Parse(output?.Data);
     this.Data       = output?.Data;
     this.ErrorName  = output?.ErrorName;
     this.ErrorValue = output?.ErrorValue;
     this.Traceback  = output?.Traceback;
 }
        private string GetExecutionOutput(SparkStatementOutput livyOutput)
        {
            if (livyOutput == null)
            {
                return(string.Empty);
            }

            if (SparkSessionStatementLivyState.Ok.Equals(livyOutput.Status, StringComparison.OrdinalIgnoreCase))
            {
                var parsedData = LivyStatementOutputParser.Parse(livyOutput.Data);
                if (parsedData is IList <PSSynapseLivyStatementOutputData> )
                {
                    var outputs  = (IList <PSSynapseLivyStatementOutputData>)parsedData;
                    var contents = outputs.Where(o => o.ContentType == ContentType.TextPlain && o.Content is string).Select(o => (string)o.Content);
                    return(string.Join(Environment.NewLine, contents));
                }
            }
            else if (SparkSessionStatementLivyState.Error.Equals(Output?.Status, StringComparison.OrdinalIgnoreCase))
            {
                var sb = new StringBuilder();
                if (livyOutput.ErrorValue != null)
                {
                    sb.AppendLine(livyOutput.ErrorValue);
                }

                if (livyOutput.Traceback != null)
                {
                    foreach (var trace in livyOutput.Traceback)
                    {
                        sb.Append(trace);
                    }
                }

                return(sb.ToString());
            }

            return(string.Empty);
        }
Ejemplo n.º 4
0
 public static SparkStatement SparkStatement(int id = default, string code = default, string state = default, SparkStatementOutput output = default)
 {
     return(new SparkStatement(id, code, state, output));
 }