Skip to content

Commit 39ad9a2

Browse files
committed
Introduce the columnar option for SQL REST requests. (#3984)
Implements elastic/elasticsearch#39287
1 parent 9ba5d51 commit 39ad9a2

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Nest/XPack/Sql/QuerySql/QuerySqlRequest.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ public partial interface IQuerySqlRequest : ISqlRequest
1515
/// Unlike scroll, receiving the last page is enough to guarantee that the Elasticsearch state is cleared.
1616
/// </para>
1717
/// </summary>
18-
[DataMember(Name ="cursor")]
18+
[DataMember(Name="cursor")]
1919
string Cursor { get; set; }
20+
21+
/// <summary>
22+
/// Return the results in a columnar fashion: one row represents all the values of a certain column from the current page of results.
23+
/// The following formats can be returned in columnar orientation: json, yaml, cbor and smile.
24+
/// </summary>
25+
[DataMember(Name="columnar")]
26+
bool? Columnar { get; set; }
2027
}
2128

2229
public partial class QuerySqlRequest
@@ -25,6 +32,10 @@ public partial class QuerySqlRequest
2532
/// >
2633
public string Cursor { get; set; }
2734

35+
/// <inheritdoc cref="IQuerySqlRequest.Columnar" />
36+
/// >
37+
public bool? Columnar { get; set; }
38+
2839
/// <inheritdoc cref="ISqlRequest.FetchSize" />
2940
/// >
3041
public int? FetchSize { get; set; }
@@ -45,6 +56,7 @@ public partial class QuerySqlRequest
4556
public partial class QuerySqlDescriptor
4657
{
4758
string IQuerySqlRequest.Cursor { get; set; }
59+
bool? IQuerySqlRequest.Columnar { get; set; }
4860
int? ISqlRequest.FetchSize { get; set; }
4961
QueryContainer ISqlRequest.Filter { get; set; }
5062
string ISqlRequest.Query { get; set; }
@@ -70,5 +82,9 @@ public QuerySqlDescriptor Filter<T>(Func<QueryContainerDescriptor<T>, QueryConta
7082
/// <inheritdoc cref="IQuerySqlRequest.Cursor" />
7183
/// >
7284
public QuerySqlDescriptor Cursor(string cursor) => Assign(cursor, (a, v) => a.Cursor = v);
85+
86+
/// <inheritdoc cref="IQuerySqlRequest.Columnar" />
87+
/// >
88+
public QuerySqlDescriptor Columnar(bool? columnar = true) => Assign(columnar, (a, v) => a.Columnar = v);
7389
}
7490
}

src/Nest/XPack/Sql/QuerySql/QuerySqlResponse.cs

+9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ public class QuerySqlResponse : ResponseBase
2020
[DataMember(Name = "cursor")]
2121
public string Cursor { get; internal set; }
2222

23+
/// <summary>
24+
/// If <see cref="IQuerySqlRequest.Columnar"/> has been set to false, this property will contain the row values
25+
/// </summary>
2326
[DataMember(Name = "rows")]
2427
public IReadOnlyCollection<SqlRow> Rows { get; internal set; } = EmptyReadOnly<SqlRow>.Collection;
28+
29+
/// <summary>
30+
/// If <see cref="IQuerySqlRequest.Columnar"/> has been set to true, this property will contain the column values
31+
/// </summary>
32+
[DataMember(Name = "values")]
33+
public IReadOnlyCollection<SqlRow> Values { get; internal set; } = EmptyReadOnly<SqlRow>.Collection;
2534
}
2635
}

0 commit comments

Comments
 (0)