Skip to content

Commit

Permalink
Make the default non-progressive (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
AsafMah authored Nov 15, 2023
1 parent 6d09f80 commit 73fa835
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed (BREAKING)
- Queries are no longer progressive by default.
- `ResultsProgressiveDisable()` has been removed.
- Use `ResultsProgressiveEnabled()` to enable progressive queries.


## [0.14.2] - 2023-11-08

### Fixed
Expand Down
6 changes: 0 additions & 6 deletions kusto/kusto.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ func setQueryOptions(ctx context.Context, op errors.Op, query Statement, queryTy
},
}

if op == errors.OpQuery {
// We want progressive frames by default for Query(), but not Mgmt() because it uses v1 framing and ingestion endpoints
// do not support it.
opt.requestProperties.Options[RequestProgressiveEnabledValue] = true
}

for _, o := range options {
if err := o(opt); err != nil {
return nil, errors.ES(op, errors.KClientArgs, "QueryValues in the the Stmt were incorrect: %s", err).SetNoRetry()
Expand Down
8 changes: 4 additions & 4 deletions kusto/queryopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type queryOptions struct {
queryIngestion bool
}

const RequestProgressiveEnabledValue = "results_progressive_enabled"
const ResultsProgressiveEnabledValue = "results_progressive_enabled"
const NoRequestTimeoutValue = "norequesttimeout"
const NoTruncationValue = "notruncation"
const ServerTimeoutValue = "servertimeout"
Expand Down Expand Up @@ -128,10 +128,10 @@ func NoTruncation() QueryOption {
}
}

// ResultsProgressiveDisable disables the progressive query stream.
func ResultsProgressiveDisable() QueryOption {
// ResultsProgressiveEnabled enables the progressive query stream.
func ResultsProgressiveEnabled() QueryOption {
return func(q *queryOptions) error {
delete(q.requestProperties.Options, RequestProgressiveEnabledValue)
q.requestProperties.Options[ResultsProgressiveEnabledValue] = true
return nil
}
}
Expand Down
27 changes: 12 additions & 15 deletions kusto/test/etoe/etoe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ func TestQueries(t *testing.T) {
want: &[]MgmtProjectionResult{{A: "1"}, {A: "2"}},
},
{
desc: "Query: Progressive query: make sure we can convert all data types from a row",
stmt: kql.New("").AddTable(allDataTypesTable),
qcall: client.Query,
desc: "Query: Progressive query: make sure we can convert all data types from a row",
stmt: kql.New("").AddTable(allDataTypesTable),
qcall: client.Query,
options: []kusto.QueryOption{kusto.ResultsProgressiveEnabled()},
doer: func(row *table.Row, update interface{}) error {
rec := AllDataType{}
if err := row.ToStruct(&rec); err != nil {
Expand Down Expand Up @@ -310,10 +311,9 @@ func TestQueries(t *testing.T) {
want: &[]AllDataType{getExpectedResult()},
},
{
desc: "Query: Non-Progressive query: make sure we can convert all data types from a row",
stmt: kql.New("").AddTable(allDataTypesTable),
qcall: client.Query,
options: []kusto.QueryOption{kusto.ResultsProgressiveDisable()},
desc: "Query: Non-Progressive query: make sure we can convert all data types from a row",
stmt: kql.New("").AddTable(allDataTypesTable),
qcall: client.Query,
doer: func(row *table.Row, update interface{}) error {
rec := AllDataType{}
if err := row.ToStruct(&rec); err != nil {
Expand Down Expand Up @@ -382,8 +382,7 @@ func TestQueries(t *testing.T) {
"lg": int64(9223372036854775807),
"guid": uuid.MustParse("74be27de-1e4e-49d9-b579-fe0b331d3642"),
})),
qcall: client.Query,
options: []kusto.QueryOption{kusto.ResultsProgressiveDisable()},
qcall: client.Query,
doer: func(row *table.Row, update interface{}) error {
rec := AllDataType{}
if err := row.ToStruct(&rec); err != nil {
Expand Down Expand Up @@ -436,8 +435,7 @@ func TestQueries(t *testing.T) {
"lg": kusto.ParamType{Type: types.Long, Default: int64(9223372036854775807)},
"guid": kusto.ParamType{Type: types.GUID, Default: uuid.MustParse("74be27de-1e4e-49d9-b579-fe0b331d3642")},
})),
qcall: client.Query,
options: []kusto.QueryOption{kusto.ResultsProgressiveDisable()},
qcall: client.Query,
doer: func(row *table.Row, update interface{}) error {
rec := AllDataType{}
if err := row.ToStruct(&rec); err != nil {
Expand Down Expand Up @@ -475,10 +473,9 @@ func TestQueries(t *testing.T) {
want: &[]AllDataType{getExpectedResult()},
},
{
desc: "Query: make sure Dynamic data type variations can be parsed",
stmt: kql.New(`print PlainValue = dynamic('1'), PlainArray = dynamic('[1,2,3]'), PlainJson= dynamic('{ "a": 1}'), JsonArray= dynamic('[{ "a": 1}, { "a": 2}]')`),
qcall: client.Query,
options: []kusto.QueryOption{kusto.ResultsProgressiveDisable()},
desc: "Query: make sure Dynamic data type variations can be parsed",
stmt: kql.New(`print PlainValue = dynamic('1'), PlainArray = dynamic('[1,2,3]'), PlainJson= dynamic('{ "a": 1}'), JsonArray= dynamic('[{ "a": 1}, { "a": 2}]')`),
qcall: client.Query,
doer: func(row *table.Row, update interface{}) error {
rec := DynamicTypeVariations{}
if err := row.ToStruct(&rec); err != nil {
Expand Down

0 comments on commit 73fa835

Please sign in to comment.