Commit graph

105 commits

Author SHA1 Message Date
Seebs
54dbeec1af support null/non-null tests for non-BSI fields
There's a lot going on here. First, we were treating "the test is
a Condition" as implying BSI, which it doesn't anymore. Second, the
behavior of conditions was weird and BSI-specific. Third, we had
to propagate these changes and features throughout a bunch of code,
including both the core featurebase code and the DAX replacements/copies
of it, plus the SQL3 layer.

We refactor this so that tests for equality and inequality work for
non-BSI fields, so now if you accidentally use `==` in a Row call
on a non-BSI field, it still works; that's not specific to BSI
fields anymore.

We add a TrackExistence flag to fields, and propagate it through
things like our protobuf code, etcetera, so that we can successfully
create fields. Newly-created fields get this by default, because
we add it unconditionally to them, but the paths that are being
called with existing fields don't add it. So, when we "create"
(really, just load the definition of) a field from something stored
in the schema, we don't add TrackExistence to it, but any path to
creating a new field should.

A time quantum field with NoStandardView will *effectively*
lack TrackExistence.

For sets, mutexes, and time quantums with a standard view, anything
that sets bits will also set a corresponding bit for the record in
a new "existence" view. This allows us to distinguish between an
empty set and a null, and also allows null checks to be constant-time.

When clearing bits, we don't clear existence bits EXCEPT that if
you clear a bit in a mutex, *and the bit actually existed*, we clear
the existence bit. For sets and time quantums, clearing bits never
clears the existence bit.

Deleting records clears the existence bit.

We also add code to the `batch` subpackage to generate suitable
existence field bitmaps and import them. This logic correctly handles
empty sets and nils. The `batch` package does not allow specification
of anything equivalent to clearing a single bit from an existing
record, so we don't have to deal with the mutex complexity in that
case, which is good because it would be impossible.

This requires a number of other subtle changes, such as allowing
new fields to have more than one FieldOption specified for them.

We also drop the handful of implementation bits relating to the
"fullySorted" internal-use-only import flag, which existed only to
support the JSON ingest API, which we've removed.

The most dangerous part of this is that the mutex semantics are
impossible to implement on top of our existing API, because they
require us to know, not how *many* bits we cleared, but which
*specific* bits we cleared. I've implemented this as a new Tx method,
which is almost certainly going to be tech debt one day; if we some
day drop the Import API, we should remove that.

The testing for this is only currently covering the Set/Clear
behavior of PQL, and the Import API. The batch tests haven't been
written yet.

Fields that don't have existence tracking enabled refuse to perform
null/not-null tests. They should also report themselves as having
no null values -- if a record exists, sets in it are considered
empty rather than null.

The SQL3 support requires a number of subtle modifications to both
featurebase and some addon tooling. The essential thing is dropping
the unconditional translation of nil slices to non-nil empty slices
in translateResult, both in the executor and the orchestrator. We
also modify the logic that handles generating results from Extract
calls, to ensure that non-null sets get an empty slice created for
them even if they never have any values assigned.

The expected results for some tests are different now; we expect to
get nil slices, rather than 0-length non-nil slices, for fields which
were never written for a given record. Most tests were not changed.
(In every case, if a test was failing, I actually checked the logic
before changing expected results. This required a lot of tracking down
of edge cases.)

The batch package now rejects as an error attempts to clear single
bits from mutex fields, because so far as I can tell it's simply
impossible to have a roaring import that specifies the correct semantics
there; you can't tell whether to clear an existence bit without
access to the currently-set bits, which the batch API doesn't have.
We already supported the special case of specifying a clear value
of nil for clearing a mutex field; now that is the only allowed
value for a mutex field to have in row.Clears.

We change the logic for fixing up incoming view names (in two places)
to stop assuming that any view in a time field other than "" that does
not have viewStandard as a prefix is a partial time quantum name that
should have "standard_" prepended to it. This allows us to submit
bitmaps for "existence" to time quantum fields and not have them
silently transformed into "standard_existence" because that's what we'd
do with "202203".

We drop the field ClearBits method, which was totally unused.

We drop the sliceDifference function, which was used in a previous
mutex implementation and hasn't been used in ages, and the test
case for it, and the helper function used only by that test case.
2023-03-24 16:01:09 -05:00
Travis Turner
aa17b8d725
Enable linter: stylecheck (#2317)
* Enable linter: stylecheck

This enabled the stylecheck linter, but excludes some staticchecks for
now. The following are ignored because they will take a bit of time to
address, but the intention is to address them and remove them from the
exclusion list.

ST1000: at least one file in a package should have a package comment
ST1003: golang naming standards
ST1008: error should be returned as the last argument
ST1016: methods on the same type should have the same receiver name
ST1020: comment on exported function

* Address ST1015

For some reason this failed in CI but not locally. I can't figure out
why that check isn't happening locally. This just moves the switch
statements around so that the `default` is the first (or last) item.

* Adjust error string in test to match case-adjusted error

* Remove TestCloseTimeout
2023-03-14 08:45:18 -05:00
Jacob Brinlee
df7e813f01
SUP-302 (#2243)
* add ability to use Θ in all field names & with PQL
2023-02-22 11:30:14 -06:00
pokeeffe-molecula
d6d5ddb501 non-sql aggregation, top, decimal and sundries (#2328)
* fixed a bunch of issues with non-pql aggregation; moved some decimal related functionality; made top actually top (for the non-pql case); experimental create function

* drive up test coverage

(cherry picked from commit 0be0c42b66)
2022-12-12 09:01:20 -08:00
tgruben
2fc7abd72e Dataframe (#2241)
* Dataframe

(cherry picked from commit 2f1beaf119)
2022-12-12 09:01:20 -08:00
Seebs
575f2c04a5 drop invalid UTF8 encoding from encoding tests
Testing unicode is great, but we appear to have had a couple
of cases where we were using strings that weren't valid UTF8.

Weirdly, other instances of these strings work -- I think because
they're in raw quotes (backticks) rather than strings. Anyway,
this is what SonarCloud fusses about.

(cherry picked from commit ab543adbe3)
2022-12-12 09:01:20 -08:00
tgruben
751b7a74fe staticcheck fixes (#2278)
(cherry picked from commit 0aa5efcc51)
2022-11-15 11:33:10 -08:00
pokeeffe-molecula
ae3910a22b Test expression eval for tuple values in inserts (fb-1555) (#2270)
refactored comparison, equality and arithmetic expr eval for decimal data types and added a test to cover expression eval for inserts

fixed failing test

(cherry picked from commit 193ef7cba1)
2022-11-15 11:31:13 -08:00
CLoZengineer
f9ddb5d5c1
fix: updating code to meet linting requirements (#2171)
* removes unused filesize function

* removes ioutil usage

* updates ioutil.ReadAll to io.ReadAll

* updates ioutil.TempFile to os.CreateTemp

* updates ioutil.TempDir to os.MkdirTemp

* updates ioutil.ReadAll to os.ReadAll

* update ioutil.WriteFile to os.WriteFile

* updates ioutil.Discard to io.Discard

* updates ioutil.ReadDir to os.ReadDir where applicable

* removes unused code in idk

* creates type to use for context value keys

* replaces assert.Nil with assert.NoError for error checks
2022-09-29 12:34:29 -04:00
Fletcher Haynes
da9b57bd45 Updated dependency paths to reflect new repo location 2022-09-06 09:39:22 -07:00
Fletcher Haynes
eb06bb50ae Updated code to latest version for open-sourcing. 2022-09-02 13:23:39 -07:00
Ben Johnson
c7c9c1e1d7
v2.0.0
Co-authored-by: Cody Soyland <codysoyland@gmail.com>
2019-10-08 14:56:17 -06:00
Shaquille Wyan Que
44088d4f29 added check for unexpected parser error 2019-05-15 12:11:55 -05:00
Shaquille Wyan Que
6ba6218ae4 changed out of range error message name and fixed formatting 2019-05-15 11:22:04 -05:00
Shaquille Wyan Que
b770167db6 fixed formatting 2019-05-15 10:52:15 -05:00
Shaquille Wyan Que
98a864634e fixed out of bounds panic to show error 2019-05-14 16:58:03 -05:00
Seebs
77d49ded64 so much lint
So with the switch to a new linter, we get a lot of new warnings,
and the majority of them are harmless probably, but a few might be
real. Variously just use _ to suppress warnings, or report errors.
There's probably things here that deserve better fixes, but we can
always revisit it.
2019-04-16 12:07:18 -05:00
Travis Turner
bdc4f3b07e
recover the duplicate arg panic from parser, treat as error 2019-04-10 23:48:17 -05:00
Travis Turner
5f079163cb
validate (and panic) on duplicate PQL arguments 2019-04-10 16:34:30 -05:00
Matt Jaffee
5458a42ad0
add parser rule to catch old-style Range query 2019-04-04 19:46:02 -05:00
Matt Jaffee
daa87d8e12
fix staticcheck warnings 2019-01-21 14:24:11 -06:00
Yuce Tekol
dc735c17b8
Fixes #1805. Fixes Store call error messages 2019-01-16 20:52:33 +03:00
Yuce Tekol
9f6d489be8
fixes #1823. Updates tests and docs for row range 2019-01-14 14:39:08 +03:00
Travis Turner
f7e3296f62
fixes a bug on upper end of bsi range queries 2019-01-11 17:05:29 -06:00
Travis Turner
0b1fb73b14
add a test for groupby filter with RangeLTLT 2019-01-10 16:56:10 -06:00
Ben Johnson
9d1e5ca8ce
Merge Range() into Row() call.
This commit refactors the `Range()` call and merges its functionality
into the `Row()` call.
2019-01-09 15:10:49 -07:00
Matt Jaffee
81d08be044
fix PQL, Rows and Group By problems
make sure that args which are Uints are positive and return an error if not.

improve group by error messages if field for Rows query is invalid
2018-12-21 14:16:55 -06:00
Ben Johnson
727659644b
Add GroupBy filter. 2018-12-07 10:35:57 -07:00
Yuce Tekol
44e436f571
removed unused rule from peg grammar 2018-11-09 08:08:43 +03:00
Yuce Tekol
cad9d83c40
fix double escapes 2018-11-07 01:10:58 +03:00
Yuce Tekol
0c0709eb20
Merge branch 'master' into allow-backslash-cr-in-pql-strings 2018-11-06 23:28:57 +03:00
Travis Turner
5b30393bc9
upgrade peg at: github.com/pointlander/peg 2018-11-06 14:12:06 -06:00
Yuce Tekol
1e30a9372d
Disabled unquoting for single quoted attribute values; updated test 2018-11-06 22:58:37 +03:00
Yuce Tekol
b158f1c378
unquote attribute values 2018-11-06 22:47:09 +03:00
Yuce Tekol
2a8f2c2026
minor grammar fix 2018-11-06 14:09:32 +03:00
Yuce Tekol
3cb3a065dd
allow backlash, carriage return in pql strings 2018-11-01 21:56:34 +03:00
Travis Turner
3d33cdbb74
implement Store() in the executor (i.e. setRow()) 2018-10-05 08:45:07 -05:00
Travis Turner
b6e99734f0
implement ClearRow() query 2018-09-24 15:52:43 -05:00
Travis Turner
4f17dbdbf1
add support for Bool fields
prevent import of non-boolean row values to bool fields
2018-09-21 09:25:41 -05:00
Yuce Tekol
80c1a734ba
trivial 2018-09-11 20:51:32 +03:00
Yuce Tekol
aa618c30d5
Implements Query call excludeRowAttrs, excludeColumns and shards args 2018-09-10 17:29:55 +03:00
Cody Soyland
dd7b5f517b
Merge branch 'master' into 1513-metalinter-megacheck 2018-08-02 10:29:47 -05:00
Travis Turner
dfd529b2f5
update parser to handle row keys on SetRowAttrs() 2018-07-27 10:50:04 -05:00
Cody Soyland
990780bd93 Fix linter issues: staticcheck (covered by megacheck, along with gosimple and unused) 2018-07-20 11:19:24 -05:00
Cody Soyland
f01d850b17 Fix linter issues: gosimple 2018-07-20 09:06:43 -05:00
Cody Soyland
c464e0fe64 Fix linter issues: gofmt 2018-07-16 16:45:42 -05:00
Ben Johnson
bcd15ef271
peg: Allow single quoted key 'col'. 2018-07-09 18:31:27 +01:00
Cody Soyland
fb7de28557 Unexport pql.TimeFormat 2018-07-05 23:11:56 -05:00
Cody Soyland
75ea43c9da Unexport pql.Parser 2018-07-05 23:11:56 -05:00
Cody Soyland
aa7f6fca75 Unexport pql.FormatValue 2018-07-05 23:11:56 -05:00