|
8 | 8 | schema2 "github.com/QuesmaOrg/quesma/platform/schema" |
9 | 9 | "github.com/QuesmaOrg/quesma/platform/types" |
10 | 10 | "github.com/QuesmaOrg/quesma/platform/util" |
11 | | - "strings" |
12 | 11 | "sync/atomic" |
13 | 12 | "testing" |
14 | 13 |
|
@@ -465,161 +464,6 @@ func TestJsonConvertingBoolToStringAttr(t *testing.T) { |
465 | 464 | } |
466 | 465 | } |
467 | 466 |
|
468 | | -// Doesn't test for 100% equality, as map iteration order isn't deterministic, but should definitely be good enough. |
469 | | -func TestCreateTableString_1(t *testing.T) { |
470 | | - table := Table{ |
471 | | - Name: "/_bulk?refresh=false&_source_includes=originId&require_alias=true_16", |
472 | | - Cols: map[string]*Column{ |
473 | | - "doc": { |
474 | | - Name: "doc", |
475 | | - Type: MultiValueType{ |
476 | | - Name: "Tuple", |
477 | | - Cols: []*Column{ |
478 | | - { |
479 | | - Name: "Tuple", |
480 | | - Type: MultiValueType{ |
481 | | - Name: "Tuple", |
482 | | - Cols: []*Column{ |
483 | | - { |
484 | | - Name: "runAt", |
485 | | - Type: NewBaseType("DateTime64"), |
486 | | - }, |
487 | | - { |
488 | | - Name: "startedAt", |
489 | | - Type: NewBaseType("DateTime64"), |
490 | | - }, |
491 | | - { |
492 | | - Name: "Tuple", |
493 | | - Type: NewBaseType("String"), |
494 | | - }, |
495 | | - { |
496 | | - Name: "status", |
497 | | - Type: NewBaseType("String"), |
498 | | - }, |
499 | | - }, |
500 | | - }, |
501 | | - }, |
502 | | - { |
503 | | - Name: "updated_at", |
504 | | - Type: NewBaseType("DateTime64"), |
505 | | - }, |
506 | | - }, |
507 | | - }, |
508 | | - }, |
509 | | - "@timestamp": { |
510 | | - Name: "@timestamp", |
511 | | - Type: NewBaseType("DateTime64"), |
512 | | - }, |
513 | | - }, |
514 | | - Config: &ChTableConfig{ |
515 | | - HasTimestamp: true, |
516 | | - TimestampDefaultsNow: true, |
517 | | - Engine: "MergeTree", |
518 | | - OrderBy: "(@timestamp)", |
519 | | - PrimaryKey: "", |
520 | | - Ttl: "", |
521 | | - Attributes: []Attribute{ |
522 | | - NewDefaultStringAttribute(), |
523 | | - }, |
524 | | - CastUnsupportedAttrValueTypesToString: false, |
525 | | - PreferCastingToOthers: false, |
526 | | - }, |
527 | | - } |
528 | | - expectedRows := []string{ |
529 | | - `CREATE TABLE IF NOT EXISTS "/_bulk?refresh=false&_source_includes=originId&require_alias=true_16" (`, |
530 | | - `"doc" Tuple`, |
531 | | - `(`, |
532 | | - `"Tuple" Tuple`, |
533 | | - `(`, |
534 | | - `"runAt" DateTime64,`, |
535 | | - `"startedAt" DateTime64,`, |
536 | | - `"Tuple" String,`, |
537 | | - `"status" String`, |
538 | | - `),`, |
539 | | - `"updated_at" DateTime64`, |
540 | | - `),`, |
541 | | - `"@timestamp" DateTime64,`, |
542 | | - `"attributes_values" Map(String,String),`, |
543 | | - `"attributes_metadata" Map(String,String)`, |
544 | | - `)`, |
545 | | - `ENGINE = MergeTree`, |
546 | | - `ORDER BY (@timestamp)`, |
547 | | - "", |
548 | | - } |
549 | | - createTableString := table.CreateTableString() |
550 | | - for _, row := range strings.Split(createTableString, "\n") { |
551 | | - assert.Contains(t, expectedRows, strings.TrimSpace(row)) |
552 | | - } |
553 | | -} |
554 | | - |
555 | | -// Doesn't test for 100% equality, as map iteration order isn't deterministic, but should definitely be good enough. |
556 | | -func TestCreateTableString_NewDateTypes(t *testing.T) { |
557 | | - table := Table{ |
558 | | - Name: "abc", |
559 | | - Cols: map[string]*Column{ |
560 | | - "low_card_string": { |
561 | | - Name: "low_card_string", |
562 | | - Type: NewBaseType("LowCardinality(String)"), |
563 | | - Comment: "some comment 1", |
564 | | - }, |
565 | | - "uuid": { |
566 | | - Name: "uuid", |
567 | | - Type: NewBaseType("UUID"), |
568 | | - }, |
569 | | - "int32": { |
570 | | - Name: "int32", |
571 | | - Type: NewBaseType("Int32"), |
572 | | - Comment: "some comment 2", |
573 | | - }, |
574 | | - "epoch_time": { |
575 | | - Name: "epoch_time", |
576 | | - Type: NewBaseType("DateTime('Asia/Kolkata')"), |
577 | | - Modifiers: "CODEC(DoubleDelta, LZ4)", |
578 | | - }, |
579 | | - "estimated_connection_speedinkbps": { |
580 | | - Name: "estimated_connection_speedinkbps", |
581 | | - Type: NewBaseType("Float64"), |
582 | | - Modifiers: "CODEC(DoubleDelta, LZ4)", |
583 | | - }, |
584 | | - }, |
585 | | - Config: &ChTableConfig{ |
586 | | - HasTimestamp: true, |
587 | | - TimestampDefaultsNow: true, |
588 | | - Engine: "MergeTree", |
589 | | - OrderBy: "(@timestamp)", |
590 | | - PrimaryKey: "", |
591 | | - Ttl: "", |
592 | | - Attributes: []Attribute{ |
593 | | - NewDefaultInt64Attribute(), |
594 | | - }, |
595 | | - CastUnsupportedAttrValueTypesToString: true, |
596 | | - PreferCastingToOthers: true, |
597 | | - }, |
598 | | - } |
599 | | - expectedRows := []string{ |
600 | | - `CREATE TABLE IF NOT EXISTS "abc" (`, |
601 | | - `"int32" Int32 COMMENT 'some comment 2',`, |
602 | | - `"low_card_string" LowCardinality(String) COMMENT 'some comment 1',`, |
603 | | - `"uuid" UUID,`, |
604 | | - `"others" JSON,`, |
605 | | - `"attributes_int64_key" Array(String),`, |
606 | | - `"attributes_int64_value" Array(Int64),`, |
607 | | - `"attributes_values" Map(String,String),`, |
608 | | - `"attributes_metadata" Map(String,String)`, |
609 | | - `"@timestamp" DateTime64(3) DEFAULT now64(),`, |
610 | | - `"epoch_time" DateTime('Asia/Kolkata') CODEC(DoubleDelta, LZ4),`, |
611 | | - `"estimated_connection_speedinkbps" Float64 CODEC(DoubleDelta, LZ4),`, |
612 | | - `ENGINE = MergeTree`, |
613 | | - `)`, |
614 | | - `ORDER BY (@timestamp)`, |
615 | | - "", |
616 | | - } |
617 | | - createTableString := table.CreateTableString() |
618 | | - for _, row := range strings.Split(createTableString, "\n") { |
619 | | - assert.Contains(t, expectedRows, strings.TrimSpace(row)) |
620 | | - } |
621 | | -} |
622 | | - |
623 | 467 | func TestLogManager_GetTable(t *testing.T) { |
624 | 468 | tests := []struct { |
625 | 469 | name string |
|
0 commit comments