Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the columnar option for SQL REST requests. #3984

Merged
merged 2 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}