Skip to content

Commit

Permalink
Introduce the columnar option for SQL REST requests. (#3984)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebrain authored Aug 9, 2019
1 parent 802c570 commit 493bb45
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Nest/XPack/Sql/QuerySql/QuerySqlRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ public partial interface IQuerySqlRequest : ISqlRequest
/// Unlike scroll, receiving the last page is enough to guarantee that the Elasticsearch state is cleared.
/// </para>
/// </summary>
[DataMember(Name ="cursor")]
[DataMember(Name="cursor")]
string Cursor { get; set; }

/// <summary>
/// Return the results in a columnar fashion: one row represents all the values of a certain column from the current page of results.
/// The following formats can be returned in columnar orientation: json, yaml, cbor and smile.
/// </summary>
[DataMember(Name="columnar")]
bool? Columnar { get; set; }
}

public partial class QuerySqlRequest
Expand All @@ -25,6 +32,10 @@ public partial class QuerySqlRequest
/// >
public string Cursor { get; set; }

/// <inheritdoc cref="IQuerySqlRequest.Columnar" />
/// >
public bool? Columnar { get; set; }

/// <inheritdoc cref="ISqlRequest.FetchSize" />
/// >
public int? FetchSize { get; set; }
Expand All @@ -45,6 +56,7 @@ public partial class QuerySqlRequest
public partial class QuerySqlDescriptor
{
string IQuerySqlRequest.Cursor { get; set; }
bool? IQuerySqlRequest.Columnar { get; set; }
int? ISqlRequest.FetchSize { get; set; }
QueryContainer ISqlRequest.Filter { get; set; }
string ISqlRequest.Query { get; set; }
Expand All @@ -70,5 +82,9 @@ public QuerySqlDescriptor Filter<T>(Func<QueryContainerDescriptor<T>, QueryConta
/// <inheritdoc cref="IQuerySqlRequest.Cursor" />
/// >
public QuerySqlDescriptor Cursor(string cursor) => Assign(cursor, (a, v) => a.Cursor = v);

/// <inheritdoc cref="IQuerySqlRequest.Columnar" />
/// >
public QuerySqlDescriptor Columnar(bool? columnar = true) => Assign(columnar, (a, v) => a.Columnar = v);
}
}
9 changes: 9 additions & 0 deletions src/Nest/XPack/Sql/QuerySql/QuerySqlResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ public class QuerySqlResponse : ResponseBase
[DataMember(Name = "cursor")]
public string Cursor { get; internal set; }

/// <summary>
/// If <see cref="IQuerySqlRequest.Columnar"/> has been set to false, this property will contain the row values
/// </summary>
[DataMember(Name = "rows")]
public IReadOnlyCollection<SqlRow> Rows { get; internal set; } = EmptyReadOnly<SqlRow>.Collection;

/// <summary>
/// If <see cref="IQuerySqlRequest.Columnar"/> has been set to true, this property will contain the column values
/// </summary>
[DataMember(Name = "values")]
public IReadOnlyCollection<SqlRow> Values { get; internal set; } = EmptyReadOnly<SqlRow>.Collection;
}
}

0 comments on commit 493bb45

Please sign in to comment.