github.com/matrixorigin/matrixone@v1.2.0/pkg/testutil/testengine/testdata.go (about) 1 // Copyright 2022 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package testengine 16 17 import ( 18 "context" 19 "fmt" 20 21 "github.com/matrixorigin/matrixone/pkg/compress" 22 "github.com/matrixorigin/matrixone/pkg/container/batch" 23 "github.com/matrixorigin/matrixone/pkg/container/types" 24 "github.com/matrixorigin/matrixone/pkg/container/vector" 25 "github.com/matrixorigin/matrixone/pkg/logutil" 26 "github.com/matrixorigin/matrixone/pkg/testutil" 27 "github.com/matrixorigin/matrixone/pkg/vm/engine" 28 ) 29 30 var testEngineMp = testutil.TestUtilMp 31 32 func CreateR(db engine.Database) { 33 ctx := context.TODO() 34 { 35 var attrs []engine.TableDef 36 37 { 38 attrs = append(attrs, &engine.AttributeDef{ 39 Attr: engine.Attribute{ 40 Alg: compress.Lz4, 41 Name: "orderid", 42 Type: types.New(types.T_varchar, 10, 0), 43 Primary: true, 44 }}) 45 attrs = append(attrs, &engine.AttributeDef{ 46 Attr: engine.Attribute{ 47 Alg: compress.Lz4, 48 Name: "uid", 49 Type: types.T_uint32.ToType(), 50 }}) 51 attrs = append(attrs, &engine.AttributeDef{ 52 Attr: engine.Attribute{ 53 Alg: compress.Lz4, 54 Name: "price", 55 Type: types.T_float64.ToType(), 56 }}) 57 } 58 if err := db.Create(ctx, "r", attrs); err != nil { 59 logutil.Fatal(err.Error()) 60 } 61 } 62 r, err := db.Relation(ctx, "r", nil) 63 if err != nil { 64 logutil.Fatal(err.Error()) 65 } 66 { 67 bat := batch.New(true, []string{"orderid", "uid", "price"}) 68 { 69 { 70 vec := vector.NewVec(types.T_varchar.ToType()) 71 vs := make([][]byte, 10) 72 for i := 0; i < 10; i++ { 73 vs[i] = []byte(fmt.Sprintf("%v", i)) 74 } 75 // XXX MPOOL 76 if err := vector.AppendBytesList(vec, vs, nil, testEngineMp); err != nil { 77 logutil.Fatal(err.Error()) 78 } 79 bat.Vecs[0] = vec 80 } 81 { 82 vec := vector.NewVec(types.T_uint32.ToType()) 83 vs := make([]uint32, 10) 84 for i := 0; i < 10; i++ { 85 vs[i] = uint32(i % 4) 86 } 87 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 88 logutil.Fatal(err.Error()) 89 } 90 bat.Vecs[1] = vec 91 } 92 { 93 vec := vector.NewVec(types.T_float64.ToType()) 94 vs := make([]float64, 10) 95 for i := 0; i < 10; i++ { 96 vs[i] = float64(i) 97 } 98 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 99 logutil.Fatal(err.Error()) 100 } 101 bat.Vecs[2] = vec 102 } 103 } 104 if err := r.Write(ctx, bat); err != nil { 105 logutil.Fatal(err.Error()) 106 } 107 } 108 { 109 bat := batch.New(true, []string{"orderid", "uid", "price"}) 110 { 111 vec := vector.NewVec(types.T_varchar.ToType()) 112 vs := make([][]byte, 10) 113 for i := 10; i < 20; i++ { 114 vs[i-10] = []byte(fmt.Sprintf("%v", i)) 115 } 116 if err := vector.AppendBytesList(vec, vs, nil, testEngineMp); err != nil { 117 logutil.Fatal(err.Error()) 118 } 119 bat.Vecs[0] = vec 120 } 121 { 122 vec := vector.NewVec(types.T_uint32.ToType()) 123 vs := make([]uint32, 10) 124 for i := 10; i < 20; i++ { 125 vs[i-10] = uint32(i % 4) 126 } 127 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 128 logutil.Fatal(err.Error()) 129 } 130 bat.Vecs[1] = vec 131 } 132 { 133 vec := vector.NewVec(types.T_float64.ToType()) 134 vs := make([]float64, 10) 135 for i := 10; i < 20; i++ { 136 vs[i-10] = float64(i) 137 } 138 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 139 logutil.Fatal(err.Error()) 140 } 141 bat.Vecs[2] = vec 142 } 143 if err := r.Write(ctx, bat); err != nil { 144 logutil.Fatal(err.Error()) 145 } 146 } 147 } 148 149 func CreateS(db engine.Database) { 150 ctx := context.TODO() 151 { 152 var attrs []engine.TableDef 153 154 { 155 attrs = append(attrs, &engine.AttributeDef{ 156 Attr: engine.Attribute{ 157 Alg: compress.Lz4, 158 Name: "orderid", 159 Type: types.New(types.T_varchar, 10, 0), 160 Primary: true, 161 }}) 162 attrs = append(attrs, &engine.AttributeDef{ 163 Attr: engine.Attribute{ 164 Alg: compress.Lz4, 165 Name: "uid", 166 Type: types.T_uint32.ToType(), 167 }}) 168 attrs = append(attrs, &engine.AttributeDef{ 169 Attr: engine.Attribute{ 170 Alg: compress.Lz4, 171 Name: "price", 172 Type: types.T_float64.ToType(), 173 }}) 174 } 175 if err := db.Create(ctx, "s", attrs); err != nil { 176 logutil.Fatal(err.Error()) 177 } 178 } 179 r, err := db.Relation(ctx, "s", nil) 180 if err != nil { 181 logutil.Fatal(err.Error()) 182 } 183 { 184 bat := batch.New(true, []string{"orderid", "uid", "price"}) 185 { 186 { 187 vec := vector.NewVec(types.T_varchar.ToType()) 188 vs := make([][]byte, 10) 189 for i := 0; i < 10; i++ { 190 vs[i] = []byte(fmt.Sprintf("%v", 30+i)) 191 } 192 if err := vector.AppendBytesList(vec, vs, nil, testEngineMp); err != nil { 193 logutil.Fatal(err.Error()) 194 } 195 bat.Vecs[0] = vec 196 } 197 { 198 vec := vector.NewVec(types.T_uint32.ToType()) 199 vs := make([]uint32, 10) 200 for i := 0; i < 10; i++ { 201 vs[i] = uint32(i % 2) 202 } 203 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 204 logutil.Fatal(err.Error()) 205 } 206 bat.Vecs[1] = vec 207 } 208 { 209 vec := vector.NewVec(types.T_float64.ToType()) 210 vs := make([]float64, 10) 211 for i := 0; i < 10; i++ { 212 vs[i] = float64(i) 213 } 214 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 215 logutil.Fatal(err.Error()) 216 } 217 bat.Vecs[2] = vec 218 } 219 } 220 if err := r.Write(ctx, bat); err != nil { 221 logutil.Fatal(err.Error()) 222 } 223 } 224 { 225 bat := batch.New(true, []string{"orderid", "uid", "price"}) 226 { 227 vec := vector.NewVec(types.T_varchar.ToType()) 228 vs := make([][]byte, 10) 229 for i := 10; i < 20; i++ { 230 vs[i-10] = []byte(fmt.Sprintf("%v", 40+i)) 231 } 232 if err := vector.AppendBytesList(vec, vs, nil, testEngineMp); err != nil { 233 logutil.Fatal(err.Error()) 234 } 235 bat.Vecs[0] = vec 236 } 237 { 238 vec := vector.NewVec(types.T_uint32.ToType()) 239 vs := make([]uint32, 10) 240 for i := 10; i < 20; i++ { 241 vs[i-10] = uint32(i % 2) 242 } 243 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 244 logutil.Fatal(err.Error()) 245 } 246 bat.Vecs[1] = vec 247 } 248 { 249 vec := vector.NewVec(types.T_float64.ToType()) 250 vs := make([]float64, 10) 251 for i := 10; i < 20; i++ { 252 vs[i-10] = float64(i) 253 } 254 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 255 logutil.Fatal(err.Error()) 256 } 257 bat.Vecs[2] = vec 258 } 259 if err := r.Write(ctx, bat); err != nil { 260 logutil.Fatal(err.Error()) 261 } 262 } 263 } 264 265 func CreateT(db engine.Database) { 266 ctx := context.TODO() 267 { 268 var attrs []engine.TableDef 269 270 { 271 attrs = append(attrs, &engine.AttributeDef{ 272 Attr: engine.Attribute{ 273 Alg: compress.Lz4, 274 Name: "id", 275 Type: types.T_varchar.ToType(), 276 Primary: true, 277 }}) 278 attrs = append(attrs, &engine.AttributeDef{ 279 Attr: engine.Attribute{ 280 Alg: compress.Lz4, 281 Name: "price", 282 Type: types.T_float64.ToType(), 283 }}) 284 } 285 if err := db.Create(ctx, "t", attrs); err != nil { 286 logutil.Fatal(err.Error()) 287 } 288 } 289 290 } 291 292 func CreateT1(db engine.Database) { 293 ctx := context.TODO() 294 { 295 var attrs []engine.TableDef 296 297 { 298 attrs = append(attrs, &engine.AttributeDef{ 299 Attr: engine.Attribute{ 300 Alg: compress.Lz4, 301 Name: "spid", 302 Type: types.T_int32.ToType(), 303 Primary: true, 304 }}) 305 attrs = append(attrs, &engine.AttributeDef{ 306 Attr: engine.Attribute{ 307 Alg: compress.Lz4, 308 Name: "userid", 309 Type: types.T_int32.ToType(), 310 }}) 311 attrs = append(attrs, &engine.AttributeDef{ 312 Attr: engine.Attribute{ 313 Alg: compress.Lz4, 314 Name: "score", 315 Type: types.T_int8.ToType(), 316 }}) 317 } 318 if err := db.Create(ctx, "t1", attrs); err != nil { 319 logutil.Fatal(err.Error()) 320 } 321 } 322 r, err := db.Relation(ctx, "t1", nil) 323 if err != nil { 324 logutil.Fatal(err.Error()) 325 } 326 { 327 bat := batch.New(true, []string{"spid", "userid", "score"}) 328 { 329 vec := vector.NewVec(types.T_int32.ToType()) 330 vs := make([]int32, 5) 331 vs[0] = 1 332 vs[1] = 2 333 vs[2] = 2 334 vs[3] = 3 335 vs[4] = 1 336 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 337 logutil.Fatal(err.Error()) 338 } 339 bat.Vecs[0] = vec 340 } 341 { 342 vec := vector.NewVec(types.T_int32.ToType()) 343 vs := make([]int32, 5) 344 vs[0] = 1 345 vs[1] = 2 346 vs[2] = 1 347 vs[3] = 3 348 vs[4] = 1 349 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 350 logutil.Fatal(err.Error()) 351 } 352 bat.Vecs[1] = vec 353 } 354 { 355 vec := vector.NewVec(types.T_int8.ToType()) 356 vs := make([]int8, 5) 357 vs[0] = 1 358 vs[1] = 2 359 vs[2] = 4 360 vs[3] = 3 361 vs[4] = 5 362 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 363 logutil.Fatal(err.Error()) 364 } 365 bat.Vecs[2] = vec 366 } 367 if err := r.Write(ctx, bat); err != nil { 368 logutil.Fatal(err.Error()) 369 } 370 } 371 { 372 bat := batch.New(true, []string{"spid", "userid", "score"}) 373 { 374 vec := vector.NewVec(types.T_int32.ToType()) 375 vs := make([]int32, 2) 376 vs[0] = 4 377 vs[1] = 5 378 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 379 logutil.Fatal(err.Error()) 380 } 381 bat.Vecs[0] = vec 382 } 383 { 384 vec := vector.NewVec(types.T_int32.ToType()) 385 vs := make([]int32, 2) 386 vs[0] = 6 387 vs[1] = 11 388 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 389 logutil.Fatal(err.Error()) 390 } 391 bat.Vecs[1] = vec 392 } 393 { 394 vec := vector.NewVec(types.T_int8.ToType()) 395 vs := make([]int8, 2) 396 vs[0] = 10 397 vs[1] = 99 398 if err := vector.AppendFixedList(vec, vs, nil, testEngineMp); err != nil { 399 logutil.Fatal(err.Error()) 400 } 401 bat.Vecs[2] = vec 402 } 403 if err := r.Write(ctx, bat); err != nil { 404 logutil.Fatal(err.Error()) 405 } 406 } 407 } 408 409 func CreateCustomer(db engine.Database) { 410 ctx := context.TODO() 411 { 412 var attrs []engine.TableDef 413 414 { 415 attrs = append(attrs, &engine.AttributeDef{ 416 Attr: engine.Attribute{ 417 Alg: compress.Lz4, 418 Name: "c_custkey", 419 Type: types.T_int64.ToType(), 420 Primary: true, 421 }}) 422 attrs = append(attrs, &engine.AttributeDef{ 423 Attr: engine.Attribute{ 424 Alg: compress.Lz4, 425 Name: "c_name", 426 Type: types.T_varchar.ToType(), 427 }}) 428 attrs = append(attrs, &engine.AttributeDef{ 429 Attr: engine.Attribute{ 430 Alg: compress.Lz4, 431 Name: "c_address", 432 Type: types.T_varchar.ToType(), 433 }}) 434 attrs = append(attrs, &engine.AttributeDef{ 435 Attr: engine.Attribute{ 436 Alg: compress.Lz4, 437 Name: "c_city", 438 Type: types.T_varchar.ToType(), 439 }}) 440 attrs = append(attrs, &engine.AttributeDef{ 441 Attr: engine.Attribute{ 442 Alg: compress.Lz4, 443 Name: "c_nation", 444 Type: types.T_varchar.ToType(), 445 }}) 446 attrs = append(attrs, &engine.AttributeDef{ 447 Attr: engine.Attribute{ 448 Alg: compress.Lz4, 449 Name: "c_region", 450 Type: types.T_varchar.ToType(), 451 }}) 452 attrs = append(attrs, &engine.AttributeDef{ 453 Attr: engine.Attribute{ 454 Alg: compress.Lz4, 455 Name: "c_phone", 456 Type: types.T_varchar.ToType(), 457 }}) 458 attrs = append(attrs, &engine.AttributeDef{ 459 Attr: engine.Attribute{ 460 Alg: compress.Lz4, 461 Name: "c_mktsegment", 462 Type: types.T_varchar.ToType(), 463 }}) 464 } 465 if err := db.Create(ctx, "customer", attrs); err != nil { 466 logutil.Fatal(err.Error()) 467 } 468 } 469 } 470 471 func CreateLineorder(db engine.Database) { 472 ctx := context.TODO() 473 { 474 var attrs []engine.TableDef 475 476 { 477 attrs = append(attrs, &engine.AttributeDef{ 478 Attr: engine.Attribute{ 479 Alg: compress.Lz4, 480 Name: "lo_orderkey", 481 Type: types.T_int64.ToType(), 482 }}) 483 attrs = append(attrs, &engine.AttributeDef{ 484 Attr: engine.Attribute{ 485 Alg: compress.Lz4, 486 Name: "lo_linenumber", 487 Type: types.T_int64.ToType(), 488 }}) 489 attrs = append(attrs, &engine.AttributeDef{ 490 Attr: engine.Attribute{ 491 Alg: compress.Lz4, 492 Name: "lo_custkey", 493 Type: types.T_int64.ToType(), 494 }}) 495 attrs = append(attrs, &engine.AttributeDef{ 496 Attr: engine.Attribute{ 497 Alg: compress.Lz4, 498 Name: "lo_partkey", 499 Type: types.T_int64.ToType(), 500 }}) 501 attrs = append(attrs, &engine.AttributeDef{ 502 Attr: engine.Attribute{ 503 Alg: compress.Lz4, 504 Name: "lo_suppkey", 505 Type: types.T_int64.ToType(), 506 }}) 507 attrs = append(attrs, &engine.AttributeDef{ 508 Attr: engine.Attribute{ 509 Alg: compress.Lz4, 510 Name: "lo_orderdate", 511 Type: types.T_varchar.ToType(), 512 }}) 513 attrs = append(attrs, &engine.AttributeDef{ 514 Attr: engine.Attribute{ 515 Alg: compress.Lz4, 516 Name: "lo_orderpriority", 517 Type: types.T_int64.ToType(), 518 }}) 519 attrs = append(attrs, &engine.AttributeDef{ 520 Attr: engine.Attribute{ 521 Alg: compress.Lz4, 522 Name: "lo_shippriority", 523 Type: types.T_int64.ToType(), 524 }}) 525 attrs = append(attrs, &engine.AttributeDef{ 526 Attr: engine.Attribute{ 527 Alg: compress.Lz4, 528 Name: "lo_quantity", 529 Type: types.T_int64.ToType(), 530 }}) 531 attrs = append(attrs, &engine.AttributeDef{ 532 Attr: engine.Attribute{ 533 Alg: compress.Lz4, 534 Name: "lo_extendedprice", 535 Type: types.T_int64.ToType(), 536 }}) 537 attrs = append(attrs, &engine.AttributeDef{ 538 Attr: engine.Attribute{ 539 Alg: compress.Lz4, 540 Name: "lo_ordtotalprice", 541 Type: types.T_int64.ToType(), 542 }}) 543 attrs = append(attrs, &engine.AttributeDef{ 544 Attr: engine.Attribute{ 545 Alg: compress.Lz4, 546 Name: "lo_discount", 547 Type: types.T_int64.ToType(), 548 }}) 549 attrs = append(attrs, &engine.AttributeDef{ 550 Attr: engine.Attribute{ 551 Alg: compress.Lz4, 552 Name: "lo_revenue", 553 Type: types.T_int64.ToType(), 554 }}) 555 attrs = append(attrs, &engine.AttributeDef{ 556 Attr: engine.Attribute{ 557 Alg: compress.Lz4, 558 Name: "lo_supplycost", 559 Type: types.T_int64.ToType(), 560 }}) 561 attrs = append(attrs, &engine.AttributeDef{ 562 Attr: engine.Attribute{ 563 Alg: compress.Lz4, 564 Name: "lo_tax", 565 Type: types.T_int64.ToType(), 566 }}) 567 attrs = append(attrs, &engine.AttributeDef{ 568 Attr: engine.Attribute{ 569 Alg: compress.Lz4, 570 Name: "lo_commitdate", 571 Type: types.T_int64.ToType(), 572 }}) 573 attrs = append(attrs, &engine.AttributeDef{ 574 Attr: engine.Attribute{ 575 Alg: compress.Lz4, 576 Name: "lo_shipmode", 577 Type: types.T_varchar.ToType(), 578 }}) 579 } 580 if err := db.Create(ctx, "lineorder", attrs); err != nil { 581 logutil.Fatal(err.Error()) 582 } 583 } 584 } 585 586 func CreatePart(db engine.Database) { 587 ctx := context.TODO() 588 { 589 var attrs []engine.TableDef 590 591 { 592 attrs = append(attrs, &engine.AttributeDef{ 593 Attr: engine.Attribute{ 594 Alg: compress.Lz4, 595 Name: "p_partkey", 596 Type: types.T_int64.ToType(), 597 Primary: true, 598 }}) 599 attrs = append(attrs, &engine.AttributeDef{ 600 Attr: engine.Attribute{ 601 Alg: compress.Lz4, 602 Name: "p_name", 603 Type: types.T_varchar.ToType(), 604 }}) 605 attrs = append(attrs, &engine.AttributeDef{ 606 Attr: engine.Attribute{ 607 Alg: compress.Lz4, 608 Name: "p_mfgr", 609 Type: types.T_varchar.ToType(), 610 }}) 611 attrs = append(attrs, &engine.AttributeDef{ 612 Attr: engine.Attribute{ 613 Alg: compress.Lz4, 614 Name: "p_category", 615 Type: types.T_varchar.ToType(), 616 }}) 617 attrs = append(attrs, &engine.AttributeDef{ 618 Attr: engine.Attribute{ 619 Alg: compress.Lz4, 620 Name: "p_brand", 621 Type: types.T_varchar.ToType(), 622 }}) 623 attrs = append(attrs, &engine.AttributeDef{ 624 Attr: engine.Attribute{ 625 Alg: compress.Lz4, 626 Name: "p_color", 627 Type: types.T_varchar.ToType(), 628 }}) 629 attrs = append(attrs, &engine.AttributeDef{ 630 Attr: engine.Attribute{ 631 Alg: compress.Lz4, 632 Name: "p_type", 633 Type: types.T_varchar.ToType(), 634 }}) 635 attrs = append(attrs, &engine.AttributeDef{ 636 Attr: engine.Attribute{ 637 Alg: compress.Lz4, 638 Name: "p_size", 639 Type: types.T_int64.ToType(), 640 }}) 641 attrs = append(attrs, &engine.AttributeDef{ 642 Attr: engine.Attribute{ 643 Alg: compress.Lz4, 644 Name: "p_container", 645 Type: types.T_varchar.ToType(), 646 }}) 647 } 648 if err := db.Create(ctx, "part", attrs); err != nil { 649 logutil.Fatal(err.Error()) 650 } 651 } 652 } 653 654 func CreateSupplier(db engine.Database) { 655 ctx := context.TODO() 656 { 657 var attrs []engine.TableDef 658 659 { 660 attrs = append(attrs, &engine.AttributeDef{ 661 Attr: engine.Attribute{ 662 Alg: compress.Lz4, 663 Name: "s_suppkey", 664 Type: types.T_int64.ToType(), 665 Primary: true, 666 }}) 667 attrs = append(attrs, &engine.AttributeDef{ 668 Attr: engine.Attribute{ 669 Alg: compress.Lz4, 670 Name: "s_name", 671 Type: types.T_varchar.ToType(), 672 }}) 673 attrs = append(attrs, &engine.AttributeDef{ 674 Attr: engine.Attribute{ 675 Alg: compress.Lz4, 676 Name: "s_address", 677 Type: types.T_varchar.ToType(), 678 }}) 679 attrs = append(attrs, &engine.AttributeDef{ 680 Attr: engine.Attribute{ 681 Alg: compress.Lz4, 682 Name: "s_city", 683 Type: types.T_varchar.ToType(), 684 }}) 685 attrs = append(attrs, &engine.AttributeDef{ 686 Attr: engine.Attribute{ 687 Alg: compress.Lz4, 688 Name: "s_nation", 689 Type: types.T_varchar.ToType(), 690 }}) 691 attrs = append(attrs, &engine.AttributeDef{ 692 Attr: engine.Attribute{ 693 Alg: compress.Lz4, 694 Name: "s_region", 695 Type: types.T_varchar.ToType(), 696 }}) 697 attrs = append(attrs, &engine.AttributeDef{ 698 Attr: engine.Attribute{ 699 Alg: compress.Lz4, 700 Name: "s_phone", 701 Type: types.T_varchar.ToType(), 702 }}) 703 } 704 if err := db.Create(ctx, "supplier", attrs); err != nil { 705 logutil.Fatal(err.Error()) 706 } 707 } 708 } 709 710 func CreateDate(db engine.Database) { 711 ctx := context.TODO() 712 { 713 var attrs []engine.TableDef 714 715 { 716 attrs = append(attrs, &engine.AttributeDef{ 717 Attr: engine.Attribute{ 718 Alg: compress.Lz4, 719 Name: "d_datekey", 720 Type: types.T_varchar.ToType(), 721 Primary: true, 722 }}) 723 attrs = append(attrs, &engine.AttributeDef{ 724 Attr: engine.Attribute{ 725 Alg: compress.Lz4, 726 Name: "d_date", 727 Type: types.T_varchar.ToType(), 728 }}) 729 attrs = append(attrs, &engine.AttributeDef{ 730 Attr: engine.Attribute{ 731 Alg: compress.Lz4, 732 Name: "d_dayofweek", 733 Type: types.T_varchar.ToType(), 734 }}) 735 attrs = append(attrs, &engine.AttributeDef{ 736 Attr: engine.Attribute{ 737 Alg: compress.Lz4, 738 Name: "d_month", 739 Type: types.T_varchar.ToType(), 740 }}) 741 attrs = append(attrs, &engine.AttributeDef{ 742 Attr: engine.Attribute{ 743 Alg: compress.Lz4, 744 Name: "d_year", 745 Type: types.T_varchar.ToType(), 746 }}) 747 attrs = append(attrs, &engine.AttributeDef{ 748 Attr: engine.Attribute{ 749 Alg: compress.Lz4, 750 Name: "d_yearmonthnum", 751 Type: types.T_varchar.ToType(), 752 }}) 753 attrs = append(attrs, &engine.AttributeDef{ 754 Attr: engine.Attribute{ 755 Alg: compress.Lz4, 756 Name: "d_yearmonth", 757 Type: types.T_varchar.ToType(), 758 }}) 759 attrs = append(attrs, &engine.AttributeDef{ 760 Attr: engine.Attribute{ 761 Alg: compress.Lz4, 762 Name: "d_daynumnweek", 763 Type: types.T_varchar.ToType(), 764 }}) 765 attrs = append(attrs, &engine.AttributeDef{ 766 Attr: engine.Attribute{ 767 Alg: compress.Lz4, 768 Name: "d_weeknuminyear", 769 Type: types.T_varchar.ToType(), 770 }}) 771 } 772 if err := db.Create(ctx, "dates", attrs); err != nil { 773 logutil.Fatal(err.Error()) 774 } 775 } 776 } 777 778 func CreateCompressFileTable(db engine.Database) { 779 ctx := context.TODO() 780 { 781 var attrs []engine.TableDef 782 783 { 784 attrs = append(attrs, &engine.AttributeDef{ 785 Attr: engine.Attribute{ 786 Alg: compress.Lz4, 787 Name: "a", 788 Type: types.T_int32.ToType(), 789 }}) 790 attrs = append(attrs, &engine.AttributeDef{ 791 Attr: engine.Attribute{ 792 Alg: compress.Lz4, 793 Name: "b", 794 Type: types.T_int32.ToType(), 795 Primary: true, 796 }}) 797 attrs = append(attrs, &engine.AttributeDef{ 798 Attr: engine.Attribute{ 799 Alg: compress.Lz4, 800 Name: "c", 801 Type: types.T_int32.ToType(), 802 }}) 803 attrs = append(attrs, &engine.AttributeDef{ 804 Attr: engine.Attribute{ 805 Alg: compress.Lz4, 806 Name: "d", 807 Type: types.T_int32.ToType(), 808 }}) 809 } 810 if err := db.Create(ctx, "pressTbl", attrs); err != nil { 811 logutil.Fatal(err.Error()) 812 } 813 } 814 }