* Fix formatting in CLI results with custom SQLResonse.UnmarshalJSON
When I started this, it was meant to be a quick fix to address the confusing
result formats we were seeing in the CLI. For example, all large integer values
were displayed in scientifc notation. This is because we were passing the result
types from JSON (in this case, float64) into pretty print. Similarly, `IDSets`
and `StringSets` where being printed using the default go Stringer for the types
[]int64 and []string respectively.
I started by writing a customer UnmarshalJSON() method for the `SQLResponse`
type. Part of this (the part which converts data types based on header types)
was already being used in dax tests, so this just formalizes that logic as part
of the `SQLResponse` type.
Then I realized that the sql3 tests (run against the `sql3` package) were
failing because sql3 is not actually returning the `IDSets` and `StringSets`
types. A future task is to formalize return types, define them, and modify sql3
to return them. Once that is done, we can remove the "typed" switch in the
`SQLResponse` json unmarshaller.
Another significant change is the modification to the `ExprDataType` interface:
```
type ExprDataType interface {
exprDataType()
TypeName() string
TypeDescription() string
TypeInfo() map[string]interface{}
}
```
I added two more methods in order to distinguish between a type (`DECIMAL`), its
description (`DECIMAL(2)`), and its type info (`"scale": int64(2)`). Currently,
the description can be used as the field definition in a CREATE TABLE statement,
but we may want to re-think that. Also, Decimal is the only type currently using
TypeInfo.
Finally, I tried to consilidate things around `dax.FieldType` instead of
comparing against parser types outside of sql3. We still have some sql3 parser
and planner types lurking about, but we can address those in future commits.
* Add some test coverage
* smoke test expected INT, now int
* minor fixes
* Introduce WireQueryResponse and related types
This also changes dax.FieldType to dax.BaseType.
* Populate WireQueryResponse correctly
Currently this is in the http handler, and in the queryer.
* Convert sql3 and dax tests to expect pilosa.WireQueryField in results
* fix PQL tests in the SQL defs
* Address a few of the skipped sql tests in dax
(cherry picked from commit
|
||
|---|---|---|
| .. | ||
| api | ||
| bankgen | ||
| cmd | ||
| common | ||
| csv | ||
| datagen | ||
| docker-sasl | ||
| fakeidp | ||
| idktest | ||
| internal | ||
| kafka | ||
| kafka_sasl | ||
| kafka_static | ||
| kafkagen | ||
| kinesis | ||
| mds | ||
| sql | ||
| testdata | ||
| .cloud-env.template | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Dockerfile-fakeIDP | ||
| Dockerfile-test | ||
| Dockerfile-wait | ||
| dup.go | ||
| dup_arm64.go | ||
| file_with_line_delimited_values | ||
| header.go | ||
| header_test.go | ||
| idallocator.go | ||
| idallocator_test.go | ||
| ingest.go | ||
| ingest_test.go | ||
| interfaces.go | ||
| interfaces_test.go | ||
| Makefile | ||
| metrics.go | ||
| pilosa-sec-test.conf | ||
| postgres.go | ||
| progress.go | ||
| README.md | ||
| reingest_test.sh | ||
| sample.csv | ||
| test_postgres.go | ||
| tls.go | ||
| util.go | ||
| util_test.go | ||
| version.go | ||
| wait.sh | ||
idk: Ingest Development Kit
Integration tests
To run the tests, you will need to install the following dependencies:
In addition to these dependancies, you will need to be added to the moleculacorp Dockerhub account.
First start the test environment. This is a docker-compose environment that includes pilosa and a confluent kafka stack. Run the following to start those services:
make startup
To build and run the integration tests, run:
make test-run
An alternative command to use, if you're running tests locally and want human-friendly output, is:
make test-run-local
With that command you can also specify individual tests to run like this:
make test-run-local TCMD='-run=TestJustThisOne .'
Then to shut down the test environment, run:
make shutdown
You can run all of the previous commands by calling test-all:
make test-all
The previous command is equivalent to running the following:
make startup
sleep 30 # wait for services to come up
make test-run
make shutdown
To run an individual test, you can run the command directly using docker-compose. Note that you must run docker-compose build idk-test for docker to run the latest code. Modify the following as needed:
make startup
docker-compose build idk-test
docker-compose run idk-test /usr/local/go/bin/go test -count=1 -mod=vendor -run=TestCmdMainOne ./kafka
To shutdown and reset the environment:
make clean
Running dependencies locally (rather than in docker) "make test-local"
This is for running the tests locally and not in Docker... so you have to be running a bunch of stuff natively on your machine.
Run Pilosa with default config:
pilosa server
Run another pilosa like
pilosa server --config=pilosa-sec-test.conf
which will run Pilosa with TLS using certs in testenv. (make testenv first if you haven't).
You also need to be running the Confluent stack which, after you've installed it from Confluent's site might look something like:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home
confluent local destroy && confluent local start schema-registry
Or it might not! You may not need the first line, but if you have the wrong Java version by default, that's how you set it. The second line may change depending on what version of the confluent stack you get. According to
confluent version
I'm running:
Version: v0.212.0
Git Ref: 2b04985
Use the test-local make target:
make test-local
This sets a number of environment variables (which it prints when you run it), and should set them correctly if you follow the instructions above, but if you're running things on non-default ports you may need to tweak them.
CSV Ingester
- make sure you're running Pilosa (localhost:10101 for these instructions)
molecula-consumer-csv --primary-key-fields=asset_tag -i sample-index --files sample.csv
asset_tag__String,fan_time__RecordTime_2006-01-02,fan_val__String_F_YMD
ABCD,2019-01-02,70%
ABCD,2019-01-03,20%
ABCD,2019-01-04,30%
BEDF,2019-01-02,70%
BEDF,2019-01-05,90%
BEDF,2019-01-08,10%
BEDF,2019-01-08,20%
ABCD,2019-01-30,40%
Datagen
Datagen is an internal command-line tool to generate various application-specific datasets, and ingest them directly into Pilosa. After running make install, run datagen with no arguments to see a list of available "sources".
When running Datagen with local Docker stacks, make sure to add individual docker stacks to the /etc/hosts file:
127.0.0.1 kafka
127.0.0.1 pilosa
127.0.0.1 <docker stack>
ODBC Support
By default, the SQL ingester is not built with ODBC support.
This is because it uses CGO with extra dependencies, and the resulting binaries are not portable.
In order to build with ODBC support, it is necessary to install unixODBC to the system.
Then run:
make bin/molecula-consumer-sql-odbc
Different Linux distros will store certain libraries in different locations. ODBC uses dynamic library loading to handle drivers, so full static linking of dependencies is not possible. It is therefore necessary to build on a system with the same distro and the same software versions as the target machine.