├── .mvn
├── jvm.config
├── maven.config
├── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── README.md
└── extensions.xml
├── .gitignore
├── src
├── main
│ ├── resources
│ │ └── com
│ │ │ └── teradata
│ │ │ └── tpcds
│ │ │ └── distribution
│ │ │ ├── countries.dst
│ │ │ ├── genders.dst
│ │ │ ├── top_domains.dst
│ │ │ ├── call_center_classes.dst
│ │ │ ├── articles.dst
│ │ │ ├── marital_statuses.dst
│ │ │ ├── vehicle_count.dst
│ │ │ ├── call_center_hours.dst
│ │ │ ├── credit_ratings.dst
│ │ │ ├── ship_mode_type.dst
│ │ │ ├── web_page_use.dst
│ │ │ ├── ship_mode_code.dst
│ │ │ ├── buy_potential.dst
│ │ │ ├── dep_count.dst
│ │ │ ├── syllables.dst
│ │ │ ├── location_types.dst
│ │ │ ├── catalog_page_types.dst
│ │ │ ├── brand_syllables.dst
│ │ │ ├── shoe_class.dst
│ │ │ ├── music_class.dst
│ │ │ ├── men_class.dst
│ │ │ ├── women_class.dst
│ │ │ ├── children_class.dst
│ │ │ ├── item_manager_id.dst
│ │ │ ├── terminators.dst
│ │ │ ├── item_current_price.dst
│ │ │ ├── item_manufact_id.dst
│ │ │ ├── salutations.dst
│ │ │ ├── street_types.dst
│ │ │ ├── sizes.dst
│ │ │ ├── purchase_band.dst
│ │ │ ├── units.dst
│ │ │ ├── auxiliaries.dst
│ │ │ ├── ship_mode_carrier.dst
│ │ │ ├── call_centers.dst
│ │ │ ├── categories.dst
│ │ │ ├── education.dst
│ │ │ ├── sport_class.dst
│ │ │ ├── book_class.dst
│ │ │ ├── home_class.dst
│ │ │ ├── jewelry_class.dst
│ │ │ ├── electronic_class.dst
│ │ │ ├── income_band.dst
│ │ │ ├── hours.dst
│ │ │ ├── street_names.dst
│ │ │ ├── sentences.dst
│ │ │ ├── colors.dst
│ │ │ └── return_reasons.dst
│ └── java
│ │ └── com
│ │ └── teradata
│ │ └── tpcds
│ │ ├── row
│ │ ├── TableRow.java
│ │ ├── generator
│ │ │ ├── RowGenerator.java
│ │ │ ├── RowGeneratorResult.java
│ │ │ ├── ReasonRowGenerator.java
│ │ │ ├── DbgenVersionRowGenerator.java
│ │ │ ├── IncomeBandRowGenerator.java
│ │ │ ├── TimeDimRowGenerator.java
│ │ │ ├── CustomerAddressRowGenerator.java
│ │ │ ├── AbstractRowGenerator.java
│ │ │ ├── WarehouseRowGenerator.java
│ │ │ ├── ShipModeRowGenerator.java
│ │ │ └── HouseholdDemographicsRowGenerator.java
│ │ ├── ReasonRow.java
│ │ ├── IncomeBandRow.java
│ │ ├── DbgenVersionRow.java
│ │ ├── InventoryRow.java
│ │ ├── TableRowWithNulls.java
│ │ ├── HouseholdDemographicsRow.java
│ │ └── ShipModeRow.java
│ │ ├── TpcdsException.java
│ │ ├── column
│ │ ├── Column.java
│ │ ├── ReasonColumn.java
│ │ ├── IncomeBandColumn.java
│ │ ├── InventoryColumn.java
│ │ ├── DbgenVersionColumn.java
│ │ ├── ShipModeColumn.java
│ │ ├── ColumnTypes.java
│ │ ├── HouseholdDemographicsColumn.java
│ │ ├── TimeDimColumn.java
│ │ ├── CustomerDemographicsColumn.java
│ │ ├── CatalogPageColumn.java
│ │ ├── CustomerAddressColumn.java
│ │ ├── WebPageColumn.java
│ │ ├── WarehouseColumn.java
│ │ ├── CustomerColumn.java
│ │ ├── StoreReturnsColumn.java
│ │ ├── PromotionColumn.java
│ │ ├── StoreSalesColumn.java
│ │ ├── ItemColumn.java
│ │ ├── WebReturnsColumn.java
│ │ ├── DateDimColumn.java
│ │ ├── CatalogReturnsColumn.java
│ │ ├── WebSiteColumn.java
│ │ ├── StoreColumn.java
│ │ └── CallCenterColumn.java
│ │ ├── random
│ │ └── RandomNumberStream.java
│ │ ├── InvalidOptionException.java
│ │ ├── generator
│ │ ├── GeneratorColumn.java
│ │ ├── ReasonGeneratorColumn.java
│ │ ├── IncomeBandGeneratorColumn.java
│ │ ├── DbgenVersionGeneratorColumn.java
│ │ ├── InventoryGeneratorColumn.java
│ │ ├── ShipModeGeneratorColumn.java
│ │ ├── HouseholdDemographicsGeneratorColumn.java
│ │ ├── TimeDimGeneratorColumn.java
│ │ ├── CatalogPageGeneratorColumn.java
│ │ ├── CustomerDemographicsGeneratorColumn.java
│ │ ├── WebPageGeneratorColumn.java
│ │ ├── WarehouseGeneratorColumn.java
│ │ ├── CustomerAddressGeneratorColumn.java
│ │ ├── CustomerGeneratorColumn.java
│ │ ├── PromotionGeneratorColumn.java
│ │ ├── ItemGeneratorColumn.java
│ │ ├── StoreReturnsGeneratorColumn.java
│ │ ├── DateDimGeneratorColumn.java
│ │ ├── StoreSalesGeneratorColumn.java
│ │ ├── WebSiteGeneratorColumn.java
│ │ ├── WebReturnsGeneratorColumn.java
│ │ ├── CallCenterGeneratorColumn.java
│ │ ├── StoreGeneratorColumn.java
│ │ └── CatalogReturnsGeneratorColumn.java
│ │ ├── distribution
│ │ ├── ReturnReasonsDistribution.java
│ │ ├── TopDomainsDistribution.java
│ │ ├── WebPageUseDistribution.java
│ │ ├── CatalogPageDistributions.java
│ │ ├── LocationTypesDistribution.java
│ │ ├── ShipModeDistributions.java
│ │ ├── CallCenterDistributions.java
│ │ └── AddressDistributions.java
│ │ ├── PseudoTableScalingInfos.java
│ │ ├── Nulls.java
│ │ ├── BusinessKeyGenerator.java
│ │ ├── Permutations.java
│ │ ├── Driver.java
│ │ └── TableFlags.java
├── license
│ └── LICENSE-HEADER.txt
└── test
│ └── java
│ └── com
│ └── teradata
│ └── tpcds
│ ├── distribution
│ ├── SentencesDistributionTest.java
│ ├── TestingRandomNumberStream.java
│ └── StreetNamesDistributionTest.java
│ ├── DbgenVersionTest.java
│ └── SlowlyChangingDimensionUtilsTest.java
└── .travis.yml
/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | -Xmx8192m
2 |
--------------------------------------------------------------------------------
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -b multithreaded
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | *.idea
3 | *.iml
4 | *.dat
5 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Teradata/tpcds/HEAD/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
2 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/countries.dst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Teradata/tpcds/HEAD/src/main/resources/com/teradata/tpcds/distribution/countries.dst
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/genders.dst:
--------------------------------------------------------------------------------
1 | -- gender
2 | -- values weights
3 | -- ====== ==========
4 | -- 1. gender 1. uniform
5 | ------
6 | M: 50
7 | F: 50
8 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/top_domains.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- top_domains
3 | -- values weights
4 | -- ====== =========
5 | -- 1. domain suffix 1. uniform
6 | ------
7 | com: 1
8 | org: 1
9 | edu: 1
10 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/call_center_classes.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- call_center_class
3 | -- values weights
4 | -- -----------------------
5 | -- 1. class 1. uniform
6 | ------
7 | small: 1
8 | medium: 1
9 | large: 1
10 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/articles.dst:
--------------------------------------------------------------------------------
1 | -- articles
2 | -- from the common word list
3 | -- values weights
4 | -- ======= =======
5 | -- 1. article 1. weight
6 | ------
7 | the:163
8 | a:504
9 | an:9
10 | no:3
11 | every:1
12 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/marital_statuses.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- marital_status
3 | -- values weights
4 | -- ====== =========
5 | -- 1. marital_status 1. uniform
6 | ------
7 | M: 1
8 | S: 1
9 | D: 1
10 | W: 1
11 | U: 1
12 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/vehicle_count.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- vehicle_count
3 | ------
4 | -- values weights
5 | -- ====== =======
6 | -- 1. count 1. weight
7 | -----------------------
8 | 0: 17
9 | 1: 17
10 | 2: 35
11 | 3: 22
12 | 4: 5
13 | -1: 4
14 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/call_center_hours.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- call_center_hours
3 | -- values weights
4 | -- ======= ==========
5 | -- 1. hours 1. weighted
6 | ------
7 | 8AM-4PM: 10
8 | 8AM-12AM: 2
9 | 8AM-8AM: 1
10 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/credit_ratings.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- credit_rating
3 | -- values weights
4 | -- ====== ========
5 | -- 1. credit rating 1. distribution
6 | ------
7 | Good: 65
8 | Low Risk: 25
9 | High Risk: 10
10 | Unknown: 4
11 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/ship_mode_type.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- ship_mode_type
3 | -- values weights
4 | -- -----------------------
5 | -- 1. type 1. uniform
6 | ------
7 | REGULAR: 1
8 | EXPRESS: 1
9 | NEXT DAY: 1
10 | OVERNIGHT: 1
11 | TWO DAY: 1
12 | LIBRARY: 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/web_page_use.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- web_page_use
3 | -- values weights
4 | -- -----------------------
5 | -- 1. type 1. uniform
6 | ------
7 | general: 1
8 | order: 1
9 | welcome: 1
10 | ad: 1
11 | feedback: 1
12 | protected: 1
13 | dynamic: 1
14 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/ship_mode_code.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- ship_mode_code
3 | -- values weights
4 | -- -----------------------
5 | -- 1. code 1. uniform
6 | ------
7 | AIR: 1
8 | SURFACE: 1
9 | SEA: 1
10 | BIKE: 1
11 | HAND CARRY: 1
12 | MESSENGER: 1
13 | COURIER: 1
14 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/buy_potential.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- buy_potential
3 | ------
4 | -- values weights
5 | -- ======= =======
6 | -- 1. range 1. weight
7 | ----------------------
8 | 0-500: 17
9 | 501-1000: 17
10 | 1001-5000: 35
11 | 5001-10000: 22
12 | >10000: 5
13 | Unknown: 4
14 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/dep_count.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- dependent_count
3 | ------
4 | -- values weights
5 | -- ====== =======
6 | -- 1. count 1. weight
7 | -----------------------
8 | 0: 25
9 | 1: 25
10 | 2: 10
11 | 3: 10
12 | 4: 8
13 | 5: 8
14 | 6: 5
15 | 7: 5
16 | 8: 2
17 | 9: 2
18 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/syllables.dst:
--------------------------------------------------------------------------------
1 | --
2 | -- syllables.dst
3 | -- values weights
4 | -- ====== =========
5 | -- 1. syllable 1. uniform
6 | ---------
7 | bar:1
8 | ought:1
9 | able:1
10 | pri:1
11 | ese:1
12 | anti:1
13 | cally:1
14 | ation:1
15 | eing:1
16 | n st:1
17 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/location_types.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- location_type
3 | -- values weights
4 | -- ======= =======
5 | -- 1. location type 1. uniform
6 | -- 2. distribution freq
7 | ------
8 | single family: 1, 50
9 | condo: 1, 25
10 | apartment: 1, 25
11 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/catalog_page_types.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- catalog_page_type
3 | -- values weights
4 | -- -----------------------
5 | -- 1. content type 1. distribution freq
6 | -- 2. sales volume
7 | ------
8 | bi-annual: 1, 50
9 | quarterly: 4, 25
10 | monthly: 12, 25
11 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/brand_syllables.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- brand_syllables
3 | -- values weights
4 | -- --------------------------
5 | -- 1. syllable 1. uniform
6 | ------
7 | univ: 1
8 | amalg: 1
9 | importo:1
10 | exporti:1
11 | edu pack:1
12 | scholar:1
13 | corp:1
14 | brand:1
15 | nameless:1
16 | maxi:1
17 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/shoe_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- shoe_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | womens, 2: 1
10 | mens, 2: 1
11 | kids, 2: 1
12 | athletic, 2: 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/music_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- music_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | rock, 2: 1
10 | country, 2: 1
11 | pop, 2: 1
12 | classical, 2: 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/men_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- men_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | accessories, 2: 1
10 | shirts, 2: 1
11 | pants, 2: 1
12 | sports-apparel, 2: 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/women_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- women_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | dresses, 2: 1
10 | fragrances, 2: 1
11 | maternity, 2: 1
12 | swimwear, 2: 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/children_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- children_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | newborn, 2: 1
10 | infants, 2: 1
11 | toddlers, 2: 1
12 | school-uniforms, 2: 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/item_manager_id.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- item_manager_id
3 | -- values weights
4 | -- -----------------------
5 | -- 1. index 1. unified
6 | -- 2. min 2. low
7 | -- 3. max 3. medium
8 | -- 4. high
9 | ------
10 | 1, 1, 33: 60, 1, 0, 0
11 | 2, 34, 66: 30, 0, 1, 0
12 | 3, 67, 100:10, 0, 0, 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/terminators.dst:
--------------------------------------------------------------------------------
1 | -- terminator.dst
2 | -- NOTE: that the additional terminator's that were listed in the C dsdgen were never read
3 | -- or included in the weight calculation, so they are omitted here.
4 | -- values weights
5 | -- ====== =========
6 | -- 1. terminator 1. weights
7 | --------
8 | .: 10
9 | ;: 2
10 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/item_current_price.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- item_current_price
3 | -- values weights
4 | -- -----------------------
5 | -- 1. index 1. unified
6 | -- 2. min 2. low
7 | -- 3. max 3. medium
8 | -- 4. high
9 | ------
10 | 1, 0.09, 4.99: 60, 1, 0, 0
11 | 2, 5.00, 9.99: 30, 0, 1, 0
12 | 3, 10.00, 99.99:10, 0, 0, 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/item_manufact_id.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- item_manufact_id
3 | -- values weights
4 | -- -----------------------
5 | -- 1. index 1. unified
6 | -- 2. min 2. low
7 | -- 3. max 3. medium
8 | -- 4. high
9 | ------
10 | 1, 1, 333: 60, 1, 0, 0
11 | 2, 334, 666: 30, 0, 1, 0
12 | 3, 667, 1000: 10, 0, 0, 1
13 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/salutations.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- salutations
3 | -- values weights
4 | -- ======= ==========
5 | -- 1. title 1. gender neutral
6 | -- 2. male
7 | -- 3. female
8 | ------
9 | Mr.: 10, 10, 0
10 | Mrs.: 10, 0, 10
11 | Ms.: 10, 0, 10
12 | Miss: 10, 0, 10
13 | Sir: 10, 10, 0
14 | Dr.: 10, 10, 10
15 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/street_types.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- street_type
3 | ------
4 | -- values weights
5 | -- ======= ======
6 | -- 1. type 1. uniform
7 | ------
8 |
9 | Street:1
10 | ST:1
11 | Avenue:1
12 | Ave:1
13 | Boulevard:1
14 | Blvd:1
15 | Road:1
16 | RD:1
17 | Parkway:1
18 | Pkwy:1
19 | Way:1
20 | Wy:1
21 | Drive:1
22 | Dr.:1
23 | Circle:1
24 | Cir.:1
25 | Lane:1
26 | Ln:1
27 | Court:1
28 | Ct.:1
29 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/sizes.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- sizes
3 | -- size of a particular item, if applicable (based on category)
4 | -- values weights
5 | -- -----------------------
6 | -- 1. size 1. uniform
7 | -- 2. for non-sized categories
8 | -- 3. size distributtion
9 | ------
10 | petite: 1, 0, 17
11 | small: 1, 0, 17
12 | medium: 1, 0, 35
13 | large: 1, 0, 22
14 | extra large: 1, 0, 17
15 | economy: 1, 0, 5
16 | N/A: 1, 1, 4
17 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/purchase_band.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- purchase_band
3 | ------
4 | -- values weights
5 | -- ====== ========
6 | -- 1. purchase_band 1. distribution
7 | ------
8 | 500: 7
9 | 1000: 7
10 | 1500: 7
11 | 2000: 7
12 | 2500: 7
13 | 3000: 7
14 | 3500: 7
15 | 4000: 5
16 | 4500: 5
17 | 5000: 5
18 | 5500: 5
19 | 6000: 5
20 | 6500: 5
21 | 7000: 5
22 | 7500: 1
23 | 8000: 1
24 | 8500: 1
25 | 9000: 1
26 | 9500: 1
27 | 10000: 1
28 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/units.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- units
3 | -- values weights
4 | -- -----------------------
5 | -- 1. unit name 1. uniform
6 | ------
7 | Unknown: 400
8 | Each: 400
9 | Dozen: 400
10 | Case: 400
11 | Pallet: 400
12 | Gross: 400
13 | Carton: 400
14 | Box: 400
15 | Bunch: 400
16 | Bundle: 400
17 | Oz: 400
18 | Lb: 400
19 | Ton: 400
20 | Ounce: 400
21 | Pound: 400
22 | Tsp: 400
23 | Tbl: 400
24 | Cup: 400
25 | Dram: 400
26 | Gram: 400
27 | N/A: 400
28 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/auxiliaries.dst:
--------------------------------------------------------------------------------
1 | -- auxiliary.dst sentence forms
2 | -- values weights
3 | -- ====== =======
4 | -- 1. auxialary 1. weight
5 | ---------
6 | will: 2
7 | will not: 1
8 | shall: 2
9 | shall not: 1
10 | may: 2
11 | may not: 1
12 | might: 2
13 | might not: 1
14 | can: 2
15 | cannot: 1
16 | could: 2
17 | could not: 1
18 | must: 2
19 | must not: 1
20 | ought to: 2
21 | used to: 2
22 | should: 2
23 | should not: 1
24 | would: 2
25 | would not: 1
26 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/ship_mode_carrier.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- ship_mode_carrier
3 | -- values weights
4 | -- -----------------------
5 | -- 1. carrier 1. uniform
6 | ------
7 | UPS: 1
8 | FEDEX: 1
9 | AIRBORNE: 1
10 | USPS: 1
11 | DHL: 1
12 | TBS: 1
13 | ZHOU: 1
14 | ZOUROS: 1
15 | MSC: 1
16 | LATVIAN: 1
17 | ALLIANCE: 1
18 | ORIENTAL: 1
19 | BARIAN: 1
20 | BOXBUNDLES: 1
21 | GREAT EASTERN: 1
22 | DIAMOND: 1
23 | RUPEKSA: 1
24 | GERMA: 1
25 | HARMSTORF: 1
26 | PRIVATECARRIER: 1
27 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/call_centers.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- call_centers
3 | -- values weights
4 | -- ====== ========
5 | -- 1. name : varchar 1. uniform
6 | -- 2. sales percentage
7 | ------
8 | New England: 1, 8
9 | NY Metro: 1, 16
10 | Mid Atlantic: 1, 10
11 | Southeastern: 1, 8
12 | North Midwest: 1, 6
13 | Central Midwest: 1, 7
14 | South Midwest: 1, 8
15 | Pacific Northwest: 1, 9
16 | California: 1, 17
17 | Southwest: 1, 7
18 | Hawaii/Alaska: 1, 3
19 | Other: 1, 1
20 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/categories.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- categories
3 | -- values weights
4 | -- -----------------------
5 | -- 1. name 1. uniform
6 | -- 2. class dist name
7 | -- 3. has sizes?
8 | ------
9 | Women, women_class, 1: 1
10 | Men, men_class, 1: 1
11 | Children, children_class, 1: 1
12 | Shoes, shoe_class, 1: 1
13 | Music, music_class, 0: 1
14 | Jewelry, jewelry_class, 0: 1
15 | Home, home_class, 0: 1
16 | Sports, sport_class, 0: 1
17 | Books, book_class, 0: 1
18 | Electronics, electronic_class, 0: 1
19 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/education.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- education
3 | -- values weights
4 | -- ======= ========
5 | -- 1. level 1. uniform
6 | -- 2. good credit distribution
7 | -- 3. low credit distribution
8 | -- 4. high risk credit distribution
9 | ------
10 | Primary: 1, 650, 250, 100
11 | Secondary: 1, 3250, 1250, 500
12 | College: 1, 650, 250, 100
13 | 2 yr Degree: 1, 975, 375, 150
14 | 4 yr Degree: 1, 650, 250, 100
15 | Advanced Degree: 1, 325, 125, 50
16 | Unknown: 1, 10, 10, 10
17 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 |
5 | cache:
6 | directories:
7 | - $HOME/.m2/repository
8 |
9 | before_install:
10 | # This is needed until Travis #4629 is fixed (https://github.com/travis-ci/travis-ci/issues/4629)
11 | - sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml
12 |
13 | before_cache:
14 | #make the cache stable between builds by removing build output
15 | - rm -rf $HOME/.m2/repository/com/teradata
16 |
17 | script: travis_wait 30 ./mvnw test
18 |
--------------------------------------------------------------------------------
/src/license/LICENSE-HEADER.txt:
--------------------------------------------------------------------------------
1 | Licensed under the Apache License, Version 2.0 (the "License");
2 | you may not use this file except in compliance with the License.
3 | You may obtain a copy of the License at
4 |
5 | http://www.apache.org/licenses/LICENSE-2.0
6 |
7 | Unless required by applicable law or agreed to in writing, software
8 | distributed under the License is distributed on an "AS IS" BASIS,
9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | See the License for the specific language governing permissions and
11 | limitations under the License.
12 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/sport_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- sport_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | athletic shoes, 10: 1
10 | baseball, 10: 1
11 | basketball, 10: 1
12 | camping, 10: 1
13 | fitness, 10: 1
14 | football, 10: 1
15 | hockey, 10: 1
16 | outdoor, 10: 1
17 | optics, 10: 1
18 | pools, 10: 1
19 | archery, 10: 1
20 | guns, 10: 1
21 | sailing, 10: 1
22 | tennis, 10: 1
23 | fishing, 10: 1
24 | golf, 10: 1
25 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/book_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- book_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | arts, 12: 1
10 | business, 12: 1
11 | computers, 12: 1
12 | entertainments, 12: 1
13 | history, 12: 1
14 | parenting, 12: 1
15 | reference, 12: 1
16 | romance, 12: 1
17 | science, 12: 1
18 | travel, 12: 1
19 | cooking, 12: 1
20 | home repair, 12: 1
21 | self-help, 12: 1
22 | sports, 12: 1
23 | fiction, 12: 1
24 | mystery, 12: 1
25 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/home_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- home_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | bathroom, 10: 1
10 | bedding, 10: 1
11 | kids, 10: 1
12 | curtains/drapes, 10: 1
13 | blinds/shades, 10: 1
14 | rugs, 10: 1
15 | decor, 10: 1
16 | lighting, 10: 1
17 | mattresses, 10: 1
18 | flatware, 10: 1
19 | accent, 10: 1
20 | paint, 10: 1
21 | wallpaper, 10: 1
22 | glassware, 10: 1
23 | tables, 10: 1
24 | furniture, 10: 1
25 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/jewelry_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- jewelry_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | birdal, 8: 1
10 | diamonds, 8: 1
11 | gold, 8: 1
12 | bracelets, 8: 1
13 | earings, 8: 1
14 | rings, 8: 1
15 | pendants, 8: 1
16 | mens watch, 8: 1
17 | womens watch, 8: 1
18 | jewelry boxes, 8: 1
19 | semi-precious, 8: 1
20 | costume, 8: 1
21 | loose stones, 8: 1
22 | estate, 8: 1
23 | custom, 8: 1
24 | consignment, 8: 1
25 |
--------------------------------------------------------------------------------
/.mvn/README.md:
--------------------------------------------------------------------------------
1 | # Parallel Build with Smart Builder
2 |
3 | Add this line if you want to use the Smart Builder with 8 threads:
4 |
5 | `-T 8 -b smart`
6 |
7 | Enabling this by default causes issues with tests as it usually consumes more resources than a normal laptop has, and it also causes issues with the maven-release-plugin.
8 |
9 | If you are working in a mode where you are not running the tests than turning on this option may be more convenient.
10 |
11 | Note that you can still use this option from the command line and it will override the default single threaded builder listed the `.mvn/maven.config`.
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/electronic_class.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- electronic_class
3 | -- second level used to populate the item hierarchy
4 | -- values weights
5 | -- -----------------------
6 | -- 1. class name 1. uniform
7 | -- 2. brand count
8 | ------
9 | cameras, 17: 1
10 | camcorders, 17: 1
11 | dvd/vcr players, 17: 1
12 | audio, 17: 1
13 | karoke, 17: 1
14 | musical, 17: 1
15 | personal, 17: 1
16 | scanners, 17: 1
17 | televisions, 17: 1
18 | memory, 17: 1
19 | disk drives, 17: 1
20 | monitors, 17: 1
21 | stereo, 17: 1
22 | automotive, 17: 1
23 | portable, 17: 1
24 | wireless, 17: 1
25 |
--------------------------------------------------------------------------------
/.mvn/extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | io.takari.maven
5 | takari-smart-builder
6 | 0.4.0
7 |
8 |
9 | io.takari.aether
10 | takari-concurrent-localrepo
11 | 0.0.7
12 |
13 |
14 | co.leantechniques
15 | maven-buildtime-extension
16 | 3.0.0
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/income_band.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- income_band
3 | ------
4 | -- values weights
5 | -- ====== ========
6 | -- 1. low 1. weight
7 | -- 2. high
8 | ------------------------
9 | 0, 10000: 7
10 | 10001, 20000: 7
11 | 20001, 30000: 7
12 | 30001, 40000: 7
13 | 40001, 50000: 7
14 | 50001, 60000: 7
15 | 60001, 70000: 7
16 | 70001, 80000: 7
17 | 80001, 90000: 7
18 | 90001, 100000: 7
19 | 100001, 110000: 7
20 | 110001, 120000: 7
21 | 120001, 130000: 8
22 | 130001, 140000: 8
23 | 140001, 150000: 8
24 | 150001, 160000: 8
25 | 160001, 170000: 8
26 | 170001, 180000: 8
27 | 180001, 190000: 8
28 | 190001, 200000: 8
29 |
30 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/TableRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import java.util.List;
18 |
19 | public interface TableRow
20 | {
21 | List getValues();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/TpcdsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | public class TpcdsException extends RuntimeException
18 | {
19 | public TpcdsException(String message)
20 | {
21 | super(message);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/Column.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.column;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | public interface Column
20 | {
21 | Table getTable();
22 |
23 | String getName();
24 |
25 | ColumnType getType();
26 |
27 | int getPosition();
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/random/RandomNumberStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.random;
16 |
17 | public interface RandomNumberStream
18 | {
19 | long nextRandom();
20 |
21 | double nextRandomDouble();
22 |
23 | void skipRows(long numberOfRows);
24 |
25 | void resetSeed();
26 |
27 | int getSeedsUsed();
28 |
29 | void resetSeedsUsed();
30 |
31 | int getSeedsPerRow();
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/RowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 |
19 | public interface RowGenerator
20 | {
21 | RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator);
22 |
23 | void consumeRemainingSeedsForRow();
24 |
25 | void skipRowsUntilStartingRowNumber(long startingRowNumber);
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/InvalidOptionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | public class InvalidOptionException extends RuntimeException
18 | {
19 | public InvalidOptionException(String optionName, String value)
20 | {
21 | this(optionName, value, "");
22 | }
23 |
24 | public InvalidOptionException(String optionName, String value, String message)
25 | {
26 | super(String.format("Invalid value for %s: \'%s\'. %s", optionName, value, message));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/com/teradata/tpcds/distribution/SentencesDistributionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import org.testng.annotations.Test;
18 |
19 | import static com.teradata.tpcds.distribution.EnglishDistributions.pickRandomSentence;
20 | import static org.testng.Assert.assertEquals;
21 |
22 | public class SentencesDistributionTest
23 | {
24 | @Test
25 | public void testEscapeBackslashes()
26 | {
27 | String result = pickRandomSentence(new TestingRandomNumberStream(2));
28 | assertEquals(result, "J, J N VT");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/GeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | /**
20 | * GeneratorColumns are columns that are used only within the context of the
21 | * generator logic. The Enums that implement this interface may include columns
22 | * that are not user visible and will sometimes omit columns that are user visible
23 | * (because those get derived from other columns).
24 | */
25 | public interface GeneratorColumn
26 | {
27 | Table getTable();
28 |
29 | int getGlobalColumnNumber();
30 |
31 | int getSeedsPerRow();
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/ReturnReasonsDistribution.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
18 |
19 | public final class ReturnReasonsDistribution
20 | {
21 | private ReturnReasonsDistribution() {}
22 |
23 | private static final StringValuesDistribution RETURN_REASONS_DISTRIBUTION = buildStringValuesDistribution("return_reasons.dst", 1, 6);
24 |
25 | public static String getReturnReasonAtIndex(int index)
26 | {
27 | return RETURN_REASONS_DISTRIBUTION.getValueAtIndex(0, index);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/hours.dst:
--------------------------------------------------------------------------------
1 | -- hours
2 | -- values weights
3 | -- ====== ==========
4 | -- 1. hour 1. uniform
5 | -- 2. AM/PM 2. store shopping (skewed)
6 | -- 3. shift 3. catalog/web shopping (skewed)
7 | -- 4. sub-shift
8 | -- 5. meal
9 | ------
10 | 0, AM, third, night, : 1, 0, 1
11 | 1, AM, third, night, : 1, 0, 2
12 | 2, AM, third, night, : 1, 0, 2
13 | 3, AM, third, night, : 1, 0, 2
14 | 4, AM, third, night, : 1, 0, 3
15 | 5, AM, third, night, : 1, 0, 3
16 | 6, AM, third, morning, breakfast: 1, 0, 3
17 | 7, AM, first, morning, breakfast: 1, 0, 4
18 | 8, AM, first, morning, breakfast: 1, 4, 4
19 | 9, AM, first, morning, breakfast: 1, 8, 5
20 | 10, AM, first, morning, : 1, 12, 5
21 | 11, AM, first, morning, : 1, 7, 5
22 | 12, PM, first, afternoon, lunch: 1, 8, 7
23 | 13, PM, first, afternoon, lunch: 1, 9, 5
24 | 14, PM, first, afternoon, lunch: 1, 12, 3
25 | 15, PM, second, afternoon, : 1, 4, 4
26 | 16, PM, second, afternoon, : 1, 4, 5
27 | 17, PM, second, evening, dinner: 1, 12, 6
28 | 18, PM, second, evening, dinner: 1, 8, 7
29 | 19, PM, second, evening, dinner: 1, 8, 8
30 | 20, PM, second, evening, : 1, 4, 7
31 | 21, PM, second, evening, : 1, 0, 5
32 | 22, PM, second, evening, : 1, 0, 3
33 | 23, PM, third, evening, : 1, 0, 1
34 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/PseudoTableScalingInfos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | import static com.teradata.tpcds.ScalingInfo.ScalingModel.LOGARITHMIC;
18 |
19 | public final class PseudoTableScalingInfos
20 | {
21 | private PseudoTableScalingInfos() {}
22 |
23 | public static final ScalingInfo CONCURRENT_WEB_SITES = new ScalingInfo(0, LOGARITHMIC, new int[]{0, 2, 3, 4, 5, 5, 5, 5, 5, 5}, 0);
24 | public static final ScalingInfo ACTIVE_CITIES = new ScalingInfo(0, LOGARITHMIC, new int[]{0, 2, 6, 18, 30, 54, 90, 165, 270, 495}, 0);
25 | public static final ScalingInfo ACTIVE_COUNTIES = new ScalingInfo(0, LOGARITHMIC, new int[]{0, 1, 3, 9, 15, 27, 45, 81, 135, 245}, 0);
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/TopDomainsDistribution.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
20 |
21 | public final class TopDomainsDistribution
22 | {
23 | private static final StringValuesDistribution TOP_DOMAINS_DISTRIBUTION = buildStringValuesDistribution("top_domains.dst", 1, 1);
24 |
25 | private TopDomainsDistribution() {}
26 |
27 | public static String pickRandomTopDomain(RandomNumberStream stream)
28 | {
29 | return TOP_DOMAINS_DISTRIBUTION.pickRandomValue(0, 0, stream);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/WebPageUseDistribution.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
20 |
21 | public class WebPageUseDistribution
22 | {
23 | private static final StringValuesDistribution WEB_PAGE_USE_DISTRIBUTION = buildStringValuesDistribution("web_page_use.dst", 1, 1);
24 |
25 | private WebPageUseDistribution() {}
26 |
27 | public static String pickRandomWebPageUseType(RandomNumberStream stream)
28 | {
29 | return WEB_PAGE_USE_DISTRIBUTION.pickRandomValue(0, 0, stream);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/CatalogPageDistributions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
20 |
21 | public final class CatalogPageDistributions
22 | {
23 | private static final StringValuesDistribution CATALOG_PAGE_TYPES_DISTRIBUTION = buildStringValuesDistribution("catalog_page_types.dst", 1, 2);
24 |
25 | private CatalogPageDistributions() {}
26 |
27 | public static String pickRandomCatalogPageType(RandomNumberStream stream)
28 | {
29 | // only the second set of weights is ever used for random picking
30 | return CATALOG_PAGE_TYPES_DISTRIBUTION.pickRandomValue(0, 1, stream);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/LocationTypesDistribution.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
20 |
21 | public final class LocationTypesDistribution
22 | {
23 | private static final StringValuesDistribution LOCATION_TYPES_DISTRIBUTION = buildStringValuesDistribution("location_types.dst", 1, 2);
24 |
25 | private LocationTypesDistribution() {}
26 |
27 | public static String pickRandomLocationType(RandomNumberStream stream, LocationTypeWeights locationTypeWeights)
28 | {
29 | return LOCATION_TYPES_DISTRIBUTION.pickRandomValue(0, locationTypeWeights.ordinal(), stream);
30 | }
31 |
32 | public enum LocationTypeWeights {
33 | UNIFORM,
34 | DISTRIBUTION_FREQUENCY
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/Nulls.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.random.RandomValueGenerator.generateUniformRandomInt;
20 | import static com.teradata.tpcds.random.RandomValueGenerator.generateUniformRandomKey;
21 |
22 | public class Nulls
23 | {
24 | private Nulls() {}
25 |
26 | public static long createNullBitMap(Table table, RandomNumberStream randomNumberStream)
27 | {
28 | int threshold = generateUniformRandomInt(0, 9999, randomNumberStream);
29 | long bitMap = generateUniformRandomKey(1, Integer.MAX_VALUE, randomNumberStream);
30 |
31 | // set the bitmap based on threshold and NOT NULL definitions
32 | if (threshold < table.getNullBasisPoints()) {
33 | return bitMap & ~table.getNotNullBitMap();
34 | }
35 |
36 | return 0;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/RowGeneratorResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.google.common.collect.ImmutableList;
18 | import com.teradata.tpcds.row.TableRow;
19 |
20 | import java.util.List;
21 |
22 | public class RowGeneratorResult
23 | {
24 | private final List rowAndChildRows;
25 | private final boolean shouldEndRow;
26 |
27 | public RowGeneratorResult(TableRow row)
28 | {
29 | this(ImmutableList.of(row), true);
30 | }
31 |
32 | public RowGeneratorResult(List rowAndChildRows, boolean shouldEndRow)
33 | {
34 | this.rowAndChildRows = rowAndChildRows;
35 | this.shouldEndRow = shouldEndRow;
36 | }
37 |
38 | public List getRowAndChildRows()
39 | {
40 | return rowAndChildRows;
41 | }
42 |
43 | public boolean shouldEndRow()
44 | {
45 | return shouldEndRow;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/com/teradata/tpcds/DbgenVersionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds;
15 |
16 | import org.testng.annotations.Test;
17 |
18 | import static com.teradata.tpcds.Results.constructResults;
19 | import static com.teradata.tpcds.Session.getDefaultSession;
20 | import static com.teradata.tpcds.Table.DBGEN_VERSION;
21 | import static com.teradata.tpcds.TableGenerator.formatRow;
22 | import static org.testng.Assert.assertTrue;
23 |
24 | public class DbgenVersionTest
25 | {
26 | private static final Session TEST_SESSION = getDefaultSession().withTable(DBGEN_VERSION);
27 |
28 | @Test
29 | public void testSingleRowCorrectlyGenerated()
30 | {
31 | Results outputRows = constructResults(DBGEN_VERSION, 1, 1, TEST_SESSION);
32 | String row = formatRow(outputRows.iterator().next().get(0), TEST_SESSION);
33 |
34 | assertTrue(row.startsWith("2.0.0|"));
35 | assertTrue(row.endsWith("|--table dbgen_version|\n"));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/ReasonGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.REASON;
20 |
21 | public enum ReasonGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | R_REASON_SK(248, 1),
25 | R_REASON_ID(249, 1),
26 | R_REASON_DESCRIPTION(250, 1),
27 | R_NULLS(251, 2);
28 |
29 | private final int globalColumnNumber;
30 | private final int seedsPerRow;
31 |
32 | ReasonGeneratorColumn(int globalColumnNumber, int seedsPerRow)
33 | {
34 | this.globalColumnNumber = globalColumnNumber;
35 | this.seedsPerRow = seedsPerRow;
36 | }
37 |
38 | @Override
39 | public Table getTable()
40 | {
41 | return REASON;
42 | }
43 |
44 | @Override
45 | public int getGlobalColumnNumber()
46 | {
47 | return globalColumnNumber;
48 | }
49 |
50 | @Override
51 | public int getSeedsPerRow()
52 | {
53 | return seedsPerRow;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/BusinessKeyGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | public final class BusinessKeyGenerator
18 | {
19 | private BusinessKeyGenerator() {}
20 |
21 | private static final String BUSINESS_KEY_CHARS = "ABCDEFGHIJKLMNOP"; // 16 possible characters for the key
22 |
23 | public static String makeBusinessKey(long primary)
24 | {
25 | String keyPart1 = longTo8CharString(primary >> 32); // create string based on the upper 32 bits
26 | String keyPart2 = longTo8CharString(primary); // create string based on the lower 32 bits
27 | return keyPart1 + keyPart2;
28 | }
29 |
30 | private static String longTo8CharString(long value)
31 | {
32 | StringBuilder builder = new StringBuilder(8);
33 | for (int i = 0; i < 8; i++) {
34 | int charIndex = (int) (value & 0xF); // The lower 4 bits of value, a number 0-15
35 | builder.append(BUSINESS_KEY_CHARS.charAt(charIndex));
36 | value >>= 4;
37 | }
38 | return builder.toString();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/ReasonColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.REASON;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.character;
21 |
22 | public enum ReasonColumn
23 | implements Column
24 | {
25 | R_REASON_SK(IDENTIFIER),
26 | R_REASON_ID(character(16)),
27 | R_REASON_DESC(character(100));
28 |
29 | private final ColumnType type;
30 |
31 | ReasonColumn(ColumnType type)
32 | {
33 | this.type = type;
34 | }
35 |
36 | @Override
37 | public Table getTable()
38 | {
39 | return REASON;
40 | }
41 |
42 | @Override
43 | public String getName()
44 | {
45 | return name().toLowerCase();
46 | }
47 |
48 | @Override
49 | public ColumnType getType()
50 | {
51 | return type;
52 | }
53 |
54 | @Override
55 | public int getPosition()
56 | {
57 | return ordinal();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/IncomeBandGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.INCOME_BAND;
20 |
21 | public enum IncomeBandGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | IB_INCOME_BAND_ID(194, 1),
25 | IB_LOWER_BOUND(195, 1),
26 | IB_UPPER_BOUND(196, 1),
27 | IB_NULLS(197, 2);
28 |
29 | private final int globalColumnNumber;
30 | private final int seedsPerRow;
31 |
32 | IncomeBandGeneratorColumn(int globalColumnNumber, int seedsPerRow)
33 | {
34 | this.globalColumnNumber = globalColumnNumber;
35 | this.seedsPerRow = seedsPerRow;
36 | }
37 |
38 | @Override
39 | public Table getTable()
40 | {
41 | return INCOME_BAND;
42 | }
43 |
44 | @Override
45 | public int getGlobalColumnNumber()
46 | {
47 | return globalColumnNumber;
48 | }
49 |
50 | @Override
51 | public int getSeedsPerRow()
52 | {
53 | return seedsPerRow;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/DbgenVersionGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.generator;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.DBGEN_VERSION;
19 |
20 | public enum DbgenVersionGeneratorColumn
21 | implements GeneratorColumn
22 | {
23 | DV_VERSION(476, 1),
24 | DV_CREATE_DATE(477, 1),
25 | DV_CREATE_TIME(478, 1),
26 | DV_CMDLINE_ARGS(479, 1);
27 |
28 | private final int globalColumnNumber;
29 | private final int seedsPerRow;
30 |
31 | DbgenVersionGeneratorColumn(int globalColumnNumber, int seedsPerRow)
32 | {
33 | this.globalColumnNumber = globalColumnNumber;
34 | this.seedsPerRow = seedsPerRow;
35 | }
36 |
37 | @Override
38 | public Table getTable()
39 | {
40 | return DBGEN_VERSION;
41 | }
42 |
43 | @Override
44 | public int getGlobalColumnNumber()
45 | {
46 | return globalColumnNumber;
47 | }
48 |
49 | @Override
50 | public int getSeedsPerRow()
51 | {
52 | return seedsPerRow;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/IncomeBandColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.INCOME_BAND;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 |
22 | public enum IncomeBandColumn
23 | implements Column
24 | {
25 | IB_INCOME_BAND_SK(IDENTIFIER),
26 | IB_LOWER_BOUND(INTEGER),
27 | IB_UPPER_BOUND(INTEGER);
28 |
29 | private final ColumnType type;
30 |
31 | IncomeBandColumn(ColumnType type)
32 | {
33 | this.type = type;
34 | }
35 |
36 | @Override
37 | public Table getTable()
38 | {
39 | return INCOME_BAND;
40 | }
41 |
42 | @Override
43 | public String getName()
44 | {
45 | return name().toLowerCase();
46 | }
47 |
48 | @Override
49 | public ColumnType getType()
50 | {
51 | return type;
52 | }
53 |
54 | @Override
55 | public int getPosition()
56 | {
57 | return ordinal();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/InventoryGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.INVENTORY;
20 |
21 | public enum InventoryGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | INV_DATE_SK(198, 1),
25 | INV_ITEM_SK(199, 1),
26 | INV_WAREHOUSE_SK(200, 1),
27 | INV_QUANTITY_ON_HAND(201, 1),
28 | INV_NULLS(202, 2);
29 |
30 | private final int globalColumnNumber;
31 | private final int seedsPerRow;
32 |
33 | InventoryGeneratorColumn(int globalColumnNumber, int seedsPerRow)
34 | {
35 | this.globalColumnNumber = globalColumnNumber;
36 | this.seedsPerRow = seedsPerRow;
37 | }
38 |
39 | @Override
40 | public Table getTable()
41 | {
42 | return INVENTORY;
43 | }
44 |
45 | @Override
46 | public int getGlobalColumnNumber()
47 | {
48 | return globalColumnNumber;
49 | }
50 |
51 | @Override
52 | public int getSeedsPerRow()
53 | {
54 | return seedsPerRow;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/InventoryColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.INVENTORY;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 |
22 | public enum InventoryColumn
23 | implements Column
24 | {
25 | INV_DATE_SK(IDENTIFIER),
26 | INV_ITEM_SK(IDENTIFIER),
27 | INV_WAREHOUSE_SK(IDENTIFIER),
28 | INV_QUANTITY_ON_HAND(INTEGER);
29 |
30 | private final ColumnType type;
31 |
32 | InventoryColumn(ColumnType type)
33 | {
34 | this.type = type;
35 | }
36 |
37 | @Override
38 | public Table getTable()
39 | {
40 | return INVENTORY;
41 | }
42 |
43 | @Override
44 | public String getName()
45 | {
46 | return name().toLowerCase();
47 | }
48 |
49 | @Override
50 | public ColumnType getType()
51 | {
52 | return type;
53 | }
54 |
55 | @Override
56 | public int getPosition()
57 | {
58 | return ordinal();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/ShipModeGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.SHIP_MODE;
20 |
21 | public enum ShipModeGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | SM_SHIP_MODE_SK(252, 1),
25 | SM_SHIP_MODE_ID(253, 1),
26 | SM_TYPE(254, 1),
27 | SM_CODE(255, 1),
28 | SM_CONTRACT(256, 21),
29 | SM_CARRIER(257, 1),
30 | SM_NULLS(258, 2);
31 |
32 | private final int globalColumnNumber;
33 | private final int seedsPerRow;
34 |
35 | ShipModeGeneratorColumn(int globalColumnNumber, int seedsPerRow)
36 | {
37 | this.globalColumnNumber = globalColumnNumber;
38 | this.seedsPerRow = seedsPerRow;
39 | }
40 |
41 | @Override
42 | public Table getTable()
43 | {
44 | return SHIP_MODE;
45 | }
46 |
47 | @Override
48 | public int getGlobalColumnNumber()
49 | {
50 | return globalColumnNumber;
51 | }
52 |
53 | @Override
54 | public int getSeedsPerRow()
55 | {
56 | return seedsPerRow;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/com/teradata/tpcds/distribution/TestingRandomNumberStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | /**
20 | * Random number stream with constant output for testing purposes
21 | */
22 | public class TestingRandomNumberStream
23 | implements RandomNumberStream
24 | {
25 | private final long value;
26 |
27 | public TestingRandomNumberStream(long value)
28 | {
29 | this.value = value;
30 | }
31 |
32 | @Override
33 | public long nextRandom()
34 | {
35 | return value;
36 | }
37 |
38 | @Override
39 | public double nextRandomDouble()
40 | {
41 | return value * 0.5;
42 | }
43 |
44 | @Override
45 | public void skipRows(long numberOfValuesToSkip) {}
46 |
47 | @Override
48 | public void resetSeed() {}
49 |
50 | @Override
51 | public int getSeedsUsed()
52 | {
53 | return 0;
54 | }
55 |
56 | @Override
57 | public void resetSeedsUsed() {}
58 |
59 | @Override
60 | public int getSeedsPerRow()
61 | {
62 | return 0;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/DbgenVersionColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.DBGEN_VERSION;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.TIME;
21 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
22 |
23 | public enum DbgenVersionColumn
24 | implements Column
25 | {
26 | DV_VERSION(varchar(16)),
27 | DV_CREATE_DATE(DATE),
28 | DV_CREATE_TIME(TIME),
29 | DV_CMDLINE_ARGS(varchar(200));
30 |
31 | private final ColumnType type;
32 |
33 | DbgenVersionColumn(ColumnType type)
34 | {
35 | this.type = type;
36 | }
37 |
38 | @Override
39 | public Table getTable()
40 | {
41 | return DBGEN_VERSION;
42 | }
43 |
44 | @Override
45 | public String getName()
46 | {
47 | return name().toLowerCase();
48 | }
49 |
50 | @Override
51 | public ColumnType getType()
52 | {
53 | return type;
54 | }
55 |
56 | @Override
57 | public int getPosition()
58 | {
59 | return ordinal();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/Permutations.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.google.common.base.Preconditions.checkArgument;
20 | import static com.teradata.tpcds.random.RandomValueGenerator.generateUniformRandomInt;
21 |
22 | public final class Permutations
23 | {
24 | private Permutations() {}
25 |
26 | public static int[] makePermutation(int size, RandomNumberStream stream)
27 | {
28 | int[] numberSet = new int[size];
29 | for (int i = 0; i < numberSet.length; i++) {
30 | numberSet[i] = i;
31 | }
32 |
33 | for (int i = 0; i < numberSet.length; i++) {
34 | int index = generateUniformRandomInt(0, size - 1, stream);
35 | int temp = numberSet[i];
36 | numberSet[i] = numberSet[index];
37 | numberSet[index] = temp;
38 | }
39 | return numberSet;
40 | }
41 |
42 | public static int getPermutationEntry(int[] permuation, int index)
43 | {
44 | checkArgument(index >= 1, "index is not greater than or equal to 1: %s", index);
45 | return permuation[index - 1] + 1;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/ShipModeColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.SHIP_MODE;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.character;
21 |
22 | public enum ShipModeColumn
23 | implements Column
24 | {
25 | SM_SHIP_MODE_SK(IDENTIFIER),
26 | SM_SHIP_MODE_ID(character(16)),
27 | SM_TYPE(character(30)),
28 | SM_CODE(character(10)),
29 | SM_CARRIER(character(20)),
30 | SM_CONTRACT(character(20));
31 |
32 | private final ColumnType type;
33 |
34 | ShipModeColumn(ColumnType type)
35 | {
36 | this.type = type;
37 | }
38 |
39 | @Override
40 | public Table getTable()
41 | {
42 | return SHIP_MODE;
43 | }
44 |
45 | @Override
46 | public String getName()
47 | {
48 | return name().toLowerCase();
49 | }
50 |
51 | @Override
52 | public ColumnType getType()
53 | {
54 | return type;
55 | }
56 |
57 | @Override
58 | public int getPosition()
59 | {
60 | return ordinal();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/HouseholdDemographicsGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.HOUSEHOLD_DEMOGRAPHICS;
20 |
21 | public enum HouseholdDemographicsGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | HD_DEMO_SK(188, 1),
25 | HD_INCOME_BAND_ID(189, 1),
26 | HD_BUY_POTENTIAL(190, 1),
27 | HD_DEP_COUNT(191, 1),
28 | HD_VEHICLE_COUNT(192, 1),
29 | HD_NULLS(193, 2);
30 |
31 | private final int globalColumnNumber;
32 | private final int seedsPerRow;
33 |
34 | HouseholdDemographicsGeneratorColumn(int globalColumnNumber, int seedsPerRow)
35 | {
36 | this.globalColumnNumber = globalColumnNumber;
37 | this.seedsPerRow = seedsPerRow;
38 | }
39 |
40 | @Override
41 | public Table getTable()
42 | {
43 | return HOUSEHOLD_DEMOGRAPHICS;
44 | }
45 |
46 | @Override
47 | public int getGlobalColumnNumber()
48 | {
49 | return globalColumnNumber;
50 | }
51 |
52 | @Override
53 | public int getSeedsPerRow()
54 | {
55 | return seedsPerRow;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/test/java/com/teradata/tpcds/distribution/StreetNamesDistributionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import org.testng.annotations.Test;
18 |
19 | import static com.teradata.tpcds.distribution.AddressDistributions.StreetNamesWeights.DEFAULT;
20 | import static com.teradata.tpcds.distribution.AddressDistributions.StreetNamesWeights.HALF_EMPTY;
21 | import static com.teradata.tpcds.distribution.AddressDistributions.pickRandomStreetName;
22 | import static org.testng.Assert.assertEquals;
23 |
24 | public class StreetNamesDistributionTest
25 | {
26 | @Test
27 | public void testPickRandomStreetNameDefault() throws Exception
28 | {
29 | String result = pickRandomStreetName(DEFAULT, new TestingRandomNumberStream(7000));
30 | assertEquals(result, "Center");
31 | }
32 |
33 | @Test
34 | public void testPickRandomStreetNameHalfEmpty() throws Exception
35 | {
36 | String result = pickRandomStreetName(HALF_EMPTY, new TestingRandomNumberStream(7000));
37 | assertEquals(result, "");
38 |
39 | result = pickRandomStreetName(HALF_EMPTY, new TestingRandomNumberStream(324000));
40 | assertEquals(result, "Center");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/ColumnTypes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | // This class was derived from the TpchColumnTypes class in the following repo
17 | // https://github.com/airlift/tpch. The license for that class can be found here
18 | // https://www.apache.org/licenses/LICENSE-2.0.
19 | public class ColumnTypes
20 | {
21 | private ColumnTypes() {}
22 |
23 | public static final ColumnType INTEGER = new ColumnType(ColumnType.Base.INTEGER);
24 | public static final ColumnType IDENTIFIER = new ColumnType(ColumnType.Base.IDENTIFIER);
25 | public static final ColumnType DATE = new ColumnType(ColumnType.Base.DATE);
26 | public static final ColumnType TIME = new ColumnType(ColumnType.Base.TIME);
27 |
28 | public static ColumnType varchar(int precision)
29 | {
30 | return new ColumnType(ColumnType.Base.VARCHAR, precision);
31 | }
32 |
33 | public static ColumnType character(int precision)
34 | {
35 | return new ColumnType(ColumnType.Base.CHAR, precision);
36 | }
37 |
38 | public static ColumnType decimal(int precision, int scale)
39 | {
40 | return new ColumnType(ColumnType.Base.DECIMAL, precision, scale);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/TimeDimGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.TIME_DIM;
20 |
21 | public enum TimeDimGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | T_TIME_SK(340, 1),
25 | T_TIME_ID(341, 1),
26 | T_TIME(342, 1),
27 | T_HOUR(343, 1),
28 | T_MINUTE(344, 1),
29 | T_SECOND(345, 1),
30 | T_AM_PM(346, 1),
31 | T_SHIFT(347, 1),
32 | T_SUB_SHIFT(348, 1),
33 | T_MEAL_TIME(349, 1),
34 | T_NULLS(350, 1);
35 |
36 | private final int globalColumnNumber;
37 | private final int seedsPerRow;
38 |
39 | TimeDimGeneratorColumn(int globalColumnNumber, int seedsPerRow)
40 | {
41 | this.globalColumnNumber = globalColumnNumber;
42 | this.seedsPerRow = seedsPerRow;
43 | }
44 |
45 | @Override
46 | public Table getTable()
47 | {
48 | return TIME_DIM;
49 | }
50 |
51 | @Override
52 | public int getGlobalColumnNumber()
53 | {
54 | return globalColumnNumber;
55 | }
56 |
57 | @Override
58 | public int getSeedsPerRow()
59 | {
60 | return seedsPerRow;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/ReasonRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import java.util.List;
18 |
19 | import static com.google.common.collect.Lists.newArrayList;
20 | import static com.teradata.tpcds.generator.ReasonGeneratorColumn.R_REASON_DESCRIPTION;
21 | import static com.teradata.tpcds.generator.ReasonGeneratorColumn.R_REASON_ID;
22 | import static com.teradata.tpcds.generator.ReasonGeneratorColumn.R_REASON_SK;
23 |
24 | public class ReasonRow
25 | extends TableRowWithNulls
26 | {
27 | private final long rReasonSk;
28 | private final String rReasonId;
29 | private final String rReasonDescription;
30 |
31 | public ReasonRow(long nullBitMap, long rReasonSk, String rReasonId, String rReasonDescription)
32 | {
33 | super(nullBitMap, R_REASON_SK);
34 | this.rReasonSk = rReasonSk;
35 | this.rReasonId = rReasonId;
36 | this.rReasonDescription = rReasonDescription;
37 | }
38 |
39 | @Override
40 | public List getValues()
41 | {
42 | return newArrayList(getStringOrNullForKey(rReasonSk, R_REASON_SK),
43 | getStringOrNull(rReasonId, R_REASON_ID),
44 | getStringOrNull(rReasonDescription, R_REASON_DESCRIPTION));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/ShipModeDistributions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
18 |
19 | public class ShipModeDistributions
20 | {
21 | public static final StringValuesDistribution SHIP_MODE_CARRIER_DISTRIBUTION = buildStringValuesDistribution("ship_mode_carrier.dst", 1, 1);
22 | public static final StringValuesDistribution SHIP_MODE_CODE_DISTRIBUTION = buildStringValuesDistribution("ship_mode_code.dst", 1, 1);
23 | public static final StringValuesDistribution SHIP_MODE_TYPE_DISTRIBUTION = buildStringValuesDistribution("ship_mode_type.dst", 1, 1);
24 |
25 | private ShipModeDistributions() {}
26 |
27 | public static String getShipModeCarrierAtIndex(int index)
28 | {
29 | return SHIP_MODE_CARRIER_DISTRIBUTION.getValueAtIndex(0, index);
30 | }
31 |
32 | public static String getShipModeCodeForIndexModSize(long index)
33 | {
34 | return SHIP_MODE_CODE_DISTRIBUTION.getValueForIndexModSize(index, 0);
35 | }
36 |
37 | public static String getShipModeTypeForIndexModSize(long index)
38 | {
39 | return SHIP_MODE_TYPE_DISTRIBUTION.getValueForIndexModSize(index, 0);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/IncomeBandRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import java.util.List;
18 |
19 | import static com.google.common.collect.Lists.newArrayList;
20 | import static com.teradata.tpcds.generator.IncomeBandGeneratorColumn.IB_INCOME_BAND_ID;
21 | import static com.teradata.tpcds.generator.IncomeBandGeneratorColumn.IB_LOWER_BOUND;
22 | import static com.teradata.tpcds.generator.IncomeBandGeneratorColumn.IB_UPPER_BOUND;
23 |
24 | public class IncomeBandRow
25 | extends TableRowWithNulls
26 | {
27 | private final int ibIncomeBandId;
28 | private final int ibLowerBound;
29 | private final int ibUpperBound;
30 |
31 | public IncomeBandRow(long nullBitMap, int ibIncomeBandId, int ibLowerBound, int ibUpperBound)
32 | {
33 | super(nullBitMap, IB_INCOME_BAND_ID);
34 | this.ibIncomeBandId = ibIncomeBandId;
35 | this.ibLowerBound = ibLowerBound;
36 | this.ibUpperBound = ibUpperBound;
37 | }
38 |
39 | @Override
40 | public List getValues()
41 | {
42 | return newArrayList(getStringOrNull(ibIncomeBandId, IB_INCOME_BAND_ID),
43 | getStringOrNull(ibLowerBound, IB_LOWER_BOUND),
44 | getStringOrNull(ibUpperBound, IB_UPPER_BOUND));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/HouseholdDemographicsColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.HOUSEHOLD_DEMOGRAPHICS;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 |
23 | public enum HouseholdDemographicsColumn
24 | implements Column
25 | {
26 | HD_DEMO_SK(IDENTIFIER),
27 | HD_INCOME_BAND_SK(IDENTIFIER),
28 | HD_BUY_POTENTIAL(character(15)),
29 | HD_DEP_COUNT(INTEGER),
30 | HD_VEHICLE_COUNT(INTEGER);
31 |
32 | private final ColumnType type;
33 |
34 | HouseholdDemographicsColumn(ColumnType type)
35 | {
36 | this.type = type;
37 | }
38 |
39 | @Override
40 | public Table getTable()
41 | {
42 | return HOUSEHOLD_DEMOGRAPHICS;
43 | }
44 |
45 | @Override
46 | public String getName()
47 | {
48 | return name().toLowerCase();
49 | }
50 |
51 | @Override
52 | public ColumnType getType()
53 | {
54 | return type;
55 | }
56 |
57 | @Override
58 | public int getPosition()
59 | {
60 | return ordinal();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/CatalogPageGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.CATALOG_PAGE;
20 |
21 | public enum CatalogPageGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | CP_CATALOG_PAGE_SK(35, 1),
25 | CP_CATALOG_PAGE_ID(36, 1),
26 | CP_START_DATE_ID(37, 1),
27 | CP_END_DATE_ID(38, 1),
28 | CP_PROMO_ID(39, 1),
29 | CP_DEPARTMENT(40, 1),
30 | CP_CATALOG_NUMBER(41, 1),
31 | CP_CATALOG_PAGE_NUMBER(42, 1),
32 | CP_DESCRIPTION(43, 100), //S_CP_DESCRIPTION
33 | CP_TYPE(44, 1),
34 | CP_NULLS(45, 2);
35 |
36 | private final int globalColumnNumber;
37 | private final int seedsPerRow;
38 |
39 | CatalogPageGeneratorColumn(int globalColumnNumber, int seedsPerRow)
40 | {
41 | this.globalColumnNumber = globalColumnNumber;
42 | this.seedsPerRow = seedsPerRow;
43 | }
44 |
45 | @Override
46 | public Table getTable()
47 | {
48 | return CATALOG_PAGE;
49 | }
50 |
51 | @Override
52 | public int getGlobalColumnNumber()
53 | {
54 | return globalColumnNumber;
55 | }
56 |
57 | @Override
58 | public int getSeedsPerRow()
59 | {
60 | return seedsPerRow;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/ReasonRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.row.ReasonRow;
19 |
20 | import static com.teradata.tpcds.BusinessKeyGenerator.makeBusinessKey;
21 | import static com.teradata.tpcds.Nulls.createNullBitMap;
22 | import static com.teradata.tpcds.Table.REASON;
23 | import static com.teradata.tpcds.distribution.ReturnReasonsDistribution.getReturnReasonAtIndex;
24 | import static com.teradata.tpcds.generator.ReasonGeneratorColumn.R_NULLS;
25 |
26 | public class ReasonRowGenerator
27 | extends AbstractRowGenerator
28 | {
29 | public ReasonRowGenerator()
30 | {
31 | super(REASON);
32 | }
33 |
34 | @Override
35 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
36 | {
37 | long nullBitMap = createNullBitMap(REASON, getRandomNumberStream(R_NULLS));
38 | long rReasonSk = rowNumber;
39 | String rReasonId = makeBusinessKey(rowNumber);
40 | String rReasonDescription = getReturnReasonAtIndex((int) (rowNumber - 1));
41 |
42 | return new RowGeneratorResult(new ReasonRow(nullBitMap, rReasonSk, rReasonId, rReasonDescription));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/CustomerDemographicsGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.CUSTOMER_DEMOGRAPHICS;
20 |
21 | public enum CustomerDemographicsGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | CD_DEMO_SK(149, 1),
25 | CD_GENDER(150, 1),
26 | CD_MARITAL_STATUS(151, 1),
27 | CD_EDUCATION_STATUS(152, 1),
28 | CD_PURCHASE_ESTIMATE(153, 1),
29 | CD_CREDIT_RATING(154, 1),
30 | CD_DEP_COUNT(155, 1),
31 | CD_DEP_EMPLOYED_COUNT(156, 1),
32 | CD_DEP_COLLEGE_COUNT(157, 1),
33 | CD_NULLS(158, 2);
34 |
35 | private final int globalColumnNumber;
36 | private final int seedsPerRow;
37 |
38 | CustomerDemographicsGeneratorColumn(int globalColumnNumber, int seedsPerRow)
39 | {
40 | this.globalColumnNumber = globalColumnNumber;
41 | this.seedsPerRow = seedsPerRow;
42 | }
43 |
44 | @Override
45 | public Table getTable()
46 | {
47 | return CUSTOMER_DEMOGRAPHICS;
48 | }
49 |
50 | @Override
51 | public int getGlobalColumnNumber()
52 | {
53 | return globalColumnNumber;
54 | }
55 |
56 | @Override
57 | public int getSeedsPerRow()
58 | {
59 | return seedsPerRow;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/TimeDimColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.TIME_DIM;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 |
23 | public enum TimeDimColumn
24 | implements Column
25 | {
26 | T_TIME_SK(IDENTIFIER),
27 | T_TIME_ID(character(16)),
28 | T_TIME(INTEGER),
29 | T_HOUR(INTEGER),
30 | T_MINUTE(INTEGER),
31 | T_SECOND(INTEGER),
32 | T_AM_PM(character(2)),
33 | T_SHIFT(character(20)),
34 | T_SUB_SHIFT(character(20)),
35 | T_MEAL_TIME(character(20));
36 |
37 | private final ColumnType type;
38 |
39 | TimeDimColumn(ColumnType type)
40 | {
41 | this.type = type;
42 | }
43 |
44 | @Override
45 | public Table getTable()
46 | {
47 | return TIME_DIM;
48 | }
49 |
50 | @Override
51 | public String getName()
52 | {
53 | return name().toLowerCase();
54 | }
55 |
56 | @Override
57 | public ColumnType getType()
58 | {
59 | return type;
60 | }
61 |
62 | @Override
63 | public int getPosition()
64 | {
65 | return ordinal();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/DbgenVersionRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.row.generator;
15 |
16 | import com.teradata.tpcds.Session;
17 | import com.teradata.tpcds.Table;
18 | import com.teradata.tpcds.row.DbgenVersionRow;
19 |
20 | import java.text.DateFormat;
21 | import java.text.SimpleDateFormat;
22 | import java.util.Calendar;
23 |
24 | public class DbgenVersionRowGenerator
25 | extends AbstractRowGenerator
26 | {
27 | private static final String DBGEN_VERSION = "2.0.0";
28 |
29 | public DbgenVersionRowGenerator()
30 | {
31 | super(Table.DBGEN_VERSION);
32 | }
33 |
34 | @Override
35 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
36 | {
37 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
38 | DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
39 | Calendar calendar = Calendar.getInstance();
40 | DbgenVersionRow row = new DbgenVersionRow(
41 | 0,
42 | DBGEN_VERSION,
43 | dateFormat.format(calendar.getTime()),
44 | timeFormat.format(calendar.getTime()),
45 | session.getCommandLineArguments());
46 | return new RowGeneratorResult(row);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/com/teradata/tpcds/SlowlyChangingDimensionUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | import org.testng.annotations.Test;
18 |
19 | import static com.teradata.tpcds.SlowlyChangingDimensionUtils.getValueForSlowlyChangingDimension;
20 | import static org.testng.Assert.assertEquals;
21 |
22 | public class SlowlyChangingDimensionUtilsTest
23 | {
24 | @Test
25 | public void testUpdatesDimensionForNewKey()
26 | {
27 | int oldInt = 1;
28 | int newInt = 2;
29 | boolean isNewKey = true;
30 | int flag = 11;
31 | int result = getValueForSlowlyChangingDimension(flag, isNewKey, oldInt, newInt);
32 | assertEquals(result, newInt);
33 | }
34 |
35 | @Test
36 | public void testUpdatesDimensionForEvenFlag()
37 | {
38 | int oldInt = 1;
39 | int newInt = 2;
40 | boolean isNewKey = false;
41 | int flag = 10;
42 | int result = getValueForSlowlyChangingDimension(flag, isNewKey, oldInt, newInt);
43 | assertEquals(result, newInt);
44 | }
45 |
46 | @Test
47 | public void testDoesNotUpdateDimensionForOddFlag()
48 | {
49 | int oldInt = 1;
50 | int newInt = 2;
51 | boolean isNewKey = false;
52 | int flag = 11;
53 | int result = getValueForSlowlyChangingDimension(flag, isNewKey, oldInt, newInt);
54 | assertEquals(result, oldInt);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/WebPageGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.WEB_PAGE;
20 |
21 | public enum WebPageGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | WP_PAGE_SK(367, 1),
25 | WP_PAGE_ID(368, 1),
26 | WP_REC_START_DATE_ID(369, 1),
27 | WP_REC_END_DATE_ID(370, 1),
28 | WP_CREATION_DATE_SK(371, 2),
29 | WP_ACCESS_DATE_SK(372, 1),
30 | WP_AUTOGEN_FLAG(373, 1),
31 | WP_CUSTOMER_SK(374, 1),
32 | WP_URL(375, 1),
33 | WP_TYPE(376, 1),
34 | WP_CHAR_COUNT(377, 1),
35 | WP_LINK_COUNT(378, 1),
36 | WP_IMAGE_COUNT(379, 1),
37 | WP_MAX_AD_COUNT(380, 1),
38 | WP_NULLS(381, 2),
39 | WP_SCD(382, 1);
40 |
41 | private final int globalColumnNumber;
42 | private final int seedsPerRow;
43 |
44 | WebPageGeneratorColumn(int globalColumnNumber, int seedsPerRow)
45 | {
46 | this.globalColumnNumber = globalColumnNumber;
47 | this.seedsPerRow = seedsPerRow;
48 | }
49 |
50 | @Override
51 | public Table getTable()
52 | {
53 | return WEB_PAGE;
54 | }
55 |
56 | @Override
57 | public int getGlobalColumnNumber()
58 | {
59 | return globalColumnNumber;
60 | }
61 |
62 | @Override
63 | public int getSeedsPerRow()
64 | {
65 | return seedsPerRow;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/IncomeBandRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.row.IncomeBandRow;
19 |
20 | import static com.teradata.tpcds.Nulls.createNullBitMap;
21 | import static com.teradata.tpcds.Table.INCOME_BAND;
22 | import static com.teradata.tpcds.distribution.DemographicsDistributions.getIncomeBandLowerBoundAtIndex;
23 | import static com.teradata.tpcds.distribution.DemographicsDistributions.getIncomeBandUpperBoundAtIndex;
24 | import static com.teradata.tpcds.generator.IncomeBandGeneratorColumn.IB_NULLS;
25 |
26 | public class IncomeBandRowGenerator
27 | extends AbstractRowGenerator
28 | {
29 | public IncomeBandRowGenerator()
30 | {
31 | super(INCOME_BAND);
32 | }
33 |
34 | @Override
35 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
36 | {
37 | long nullBitMap = createNullBitMap(INCOME_BAND, getRandomNumberStream(IB_NULLS));
38 | int ibIncomeBandId = (int) rowNumber;
39 | int ibLowerBound = getIncomeBandLowerBoundAtIndex((int) rowNumber - 1);
40 | int ibUpperBound = getIncomeBandUpperBoundAtIndex((int) rowNumber - 1);
41 | return new RowGeneratorResult(new IncomeBandRow(nullBitMap, ibIncomeBandId, ibLowerBound, ibUpperBound));
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/CustomerDemographicsColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.CUSTOMER_DEMOGRAPHICS;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 |
23 | public enum CustomerDemographicsColumn
24 | implements Column
25 | {
26 | CD_DEMO_SK(IDENTIFIER),
27 | CD_GENDER(character(1)),
28 | CD_MARITAL_STATUS(character(1)),
29 | CD_EDUCATION_STATUS(character(20)),
30 | CD_PURCHASE_ESTIMATE(INTEGER),
31 | CD_CREDIT_RATING(character(10)),
32 | CD_DEP_COUNT(INTEGER),
33 | CD_DEP_EMPLOYED_COUNT(INTEGER),
34 | CD_DEP_COLLEGE_COUNT(INTEGER);
35 |
36 | private final ColumnType type;
37 |
38 | CustomerDemographicsColumn(ColumnType type)
39 | {
40 | this.type = type;
41 | }
42 |
43 | @Override
44 | public Table getTable()
45 | {
46 | return CUSTOMER_DEMOGRAPHICS;
47 | }
48 |
49 | @Override
50 | public String getName()
51 | {
52 | return name().toLowerCase();
53 | }
54 |
55 | @Override
56 | public ColumnType getType()
57 | {
58 | return type;
59 | }
60 |
61 | @Override
62 | public int getPosition()
63 | {
64 | return ordinal();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/CatalogPageColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.CATALOG_PAGE;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
23 |
24 | public enum CatalogPageColumn
25 | implements Column
26 | {
27 | CP_CATALOG_PAGE_SK(IDENTIFIER),
28 | CP_CATALOG_PAGE_ID(character(16)),
29 | CP_START_DATE_SK(INTEGER),
30 | CP_END_DATE_SK(INTEGER),
31 | CP_DEPARTMENT(varchar(50)),
32 | CP_CATALOG_NUMBER(INTEGER),
33 | CP_CATALOG_PAGE_NUMBER(INTEGER),
34 | CP_DESCRIPTION(varchar(100)),
35 | CP_TYPE(varchar(100));
36 |
37 | private final ColumnType type;
38 |
39 | CatalogPageColumn(ColumnType type)
40 | {
41 | this.type = type;
42 | }
43 |
44 | @Override
45 | public Table getTable()
46 | {
47 | return CATALOG_PAGE;
48 | }
49 |
50 | @Override
51 | public String getName()
52 | {
53 | return name().toLowerCase();
54 | }
55 |
56 | @Override
57 | public ColumnType getType()
58 | {
59 | return type;
60 | }
61 |
62 | @Override
63 | public int getPosition()
64 | {
65 | return ordinal();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/CallCenterDistributions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
20 |
21 | public final class CallCenterDistributions
22 | {
23 | private static final StringValuesDistribution CALL_CENTERS_DISTRIBUTION = buildStringValuesDistribution("call_centers.dst", 1, 2);
24 | private static final StringValuesDistribution CALL_CENTER_CLASSES_DISTRIBUTION = buildStringValuesDistribution("call_center_classes.dst", 1, 1);
25 | private static final StringValuesDistribution CALL_CENTER_HOURS_DISTRIBUTION = buildStringValuesDistribution("call_center_hours.dst", 1, 1);
26 |
27 | private CallCenterDistributions() {}
28 |
29 | public static String getCallCenterAtIndex(int i)
30 | {
31 | return CALL_CENTERS_DISTRIBUTION.getValueAtIndex(0, i);
32 | }
33 |
34 | public static int getNumberOfCallCenters()
35 | {
36 | return CALL_CENTERS_DISTRIBUTION.getSize();
37 | }
38 |
39 | public static String pickRandomCallCenterClass(RandomNumberStream stream)
40 | {
41 | return CALL_CENTER_CLASSES_DISTRIBUTION.pickRandomValue(0, 0, stream);
42 | }
43 |
44 | public static String pickRandomCallCenterHours(RandomNumberStream stream)
45 | {
46 | return CALL_CENTER_HOURS_DISTRIBUTION.pickRandomValue(0, 0, stream);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/WarehouseGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.WAREHOUSE;
20 |
21 | public enum WarehouseGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | W_WAREHOUSE_SK(351, 1),
25 | W_WAREHOUSE_ID(352, 1),
26 | W_WAREHOUSE_NAME(353, 80),
27 | W_WAREHOUSE_SQ_FT(354, 1),
28 | W_ADDRESS_STREET_NUM(355, 1),
29 | W_ADDRESS_STREET_NAME1(356, 1),
30 | W_ADDRESS_STREET_TYPE(357, 1),
31 | W_ADDRESS_SUITE_NUM(358, 1),
32 | W_ADDRESS_CITY(359, 1),
33 | W_ADDRESS_COUNTY(360, 1),
34 | W_ADDRESS_STATE(361, 1),
35 | W_ADDRESS_ZIP(362, 1),
36 | W_ADDRESS_COUNTRY(363, 1),
37 | W_ADDRESS_GMT_OFFSET(364, 1),
38 | W_NULLS(365, 2),
39 | W_WAREHOUSE_ADDRESS(366, 7);
40 |
41 | private final int globalColumnNumber;
42 | private final int seedsPerRow;
43 |
44 | WarehouseGeneratorColumn(int globalColumnNumber, int seedsPerRow)
45 | {
46 | this.globalColumnNumber = globalColumnNumber;
47 | this.seedsPerRow = seedsPerRow;
48 | }
49 |
50 | @Override
51 | public Table getTable()
52 | {
53 | return WAREHOUSE;
54 | }
55 |
56 | @Override
57 | public int getGlobalColumnNumber()
58 | {
59 | return globalColumnNumber;
60 | }
61 |
62 | @Override
63 | public int getSeedsPerRow()
64 | {
65 | return seedsPerRow;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/DbgenVersionRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.row;
15 |
16 | import java.util.List;
17 |
18 | import static com.google.common.collect.Lists.newArrayList;
19 | import static com.teradata.tpcds.generator.DbgenVersionGeneratorColumn.DV_CMDLINE_ARGS;
20 | import static com.teradata.tpcds.generator.DbgenVersionGeneratorColumn.DV_CREATE_DATE;
21 | import static com.teradata.tpcds.generator.DbgenVersionGeneratorColumn.DV_CREATE_TIME;
22 | import static com.teradata.tpcds.generator.DbgenVersionGeneratorColumn.DV_VERSION;
23 |
24 | public class DbgenVersionRow
25 | extends TableRowWithNulls
26 | {
27 | private final String dvVersion;
28 | private final String dvCreateDate;
29 | private final String dvCreateTime;
30 | private final String dvCmdlineArgs;
31 |
32 | public DbgenVersionRow(long nullBitMap, String dvVersion, String dvCreateDate, String dvCreateTime, String dvCmdlineArgs)
33 | {
34 | super(nullBitMap, DV_VERSION);
35 | this.dvVersion = dvVersion;
36 | this.dvCreateDate = dvCreateDate;
37 | this.dvCreateTime = dvCreateTime;
38 | this.dvCmdlineArgs = dvCmdlineArgs;
39 | }
40 |
41 | @Override
42 | public List getValues()
43 | {
44 | return newArrayList(getStringOrNull(dvVersion, DV_VERSION),
45 | getStringOrNull(dvCreateDate, DV_CREATE_DATE),
46 | getStringOrNull(dvCreateTime, DV_CREATE_TIME),
47 | getStringOrNull(dvCmdlineArgs, DV_CMDLINE_ARGS));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/CustomerAddressGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.CUSTOMER_ADDRESS;
20 |
21 | public enum CustomerAddressGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | CA_ADDRESS_SK(133, 1),
25 | CA_ADDRESS_ID(134, 1),
26 | CA_ADDRESS_STREET_NUM(135, 1),
27 | CA_ADDRESS_STREET_NAME(136, 1),
28 | CA_ADDRESS_STREET_TYPE(137, 1),
29 | CA_ADDRESS_SUITE_NUM(138, 1),
30 | CA_ADDRESS_CITY(139, 1),
31 | CA_ADDRESS_COUNTY(140, 1),
32 | CA_ADDRESS_STATE(141, 1),
33 | CA_ADDRESS_ZIP(142, 1),
34 | CA_ADDRESS_COUNTRY(143, 1),
35 | CA_ADDRESS_GMT_OFFSET(144, 1),
36 | CA_LOCATION_TYPE(145, 1),
37 | CA_NULLS(146, 2),
38 | CA_ADDRESS(147, 7),
39 | CA_ADDRESS_STREET_NAME2(148, 1);
40 |
41 | private final int globalColumnNumber;
42 | private final int seedsPerRow;
43 |
44 | CustomerAddressGeneratorColumn(int globalColumnNumber, int seedsPerRow)
45 | {
46 | this.globalColumnNumber = globalColumnNumber;
47 | this.seedsPerRow = seedsPerRow;
48 | }
49 |
50 | @Override
51 | public Table getTable()
52 | {
53 | return CUSTOMER_ADDRESS;
54 | }
55 |
56 | @Override
57 | public int getGlobalColumnNumber()
58 | {
59 | return globalColumnNumber;
60 | }
61 |
62 | @Override
63 | public int getSeedsPerRow()
64 | {
65 | return seedsPerRow;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/InventoryRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import java.util.List;
18 |
19 | import static com.google.common.collect.Lists.newArrayList;
20 | import static com.teradata.tpcds.generator.InventoryGeneratorColumn.INV_DATE_SK;
21 | import static com.teradata.tpcds.generator.InventoryGeneratorColumn.INV_ITEM_SK;
22 | import static com.teradata.tpcds.generator.InventoryGeneratorColumn.INV_QUANTITY_ON_HAND;
23 | import static com.teradata.tpcds.generator.InventoryGeneratorColumn.INV_WAREHOUSE_SK;
24 |
25 | public class InventoryRow
26 | extends TableRowWithNulls
27 | {
28 | private final long invDateSk;
29 | private final long invItemSk;
30 | private final long invWarehouseSk;
31 | private final int invQuantityOnHand;
32 |
33 | public InventoryRow(long nullBitMap, long invDateSk, long invItemSk, long invWarehouseSk, int invQuantityOnHand)
34 | {
35 | super(nullBitMap, INV_DATE_SK);
36 | this.invDateSk = invDateSk;
37 | this.invItemSk = invItemSk;
38 | this.invWarehouseSk = invWarehouseSk;
39 | this.invQuantityOnHand = invQuantityOnHand;
40 | }
41 |
42 | @Override
43 | public List getValues()
44 | {
45 | return newArrayList(getStringOrNullForKey(invDateSk, INV_DATE_SK),
46 | getStringOrNullForKey(invItemSk, INV_ITEM_SK),
47 | getStringOrNullForKey(invWarehouseSk, INV_WAREHOUSE_SK),
48 | getStringOrNull(invQuantityOnHand, INV_QUANTITY_ON_HAND));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/CustomerGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.CUSTOMER;
20 |
21 | public enum CustomerGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | C_CUSTOMER_SK(114, 1),
25 | C_CUSTOMER_ID(115, 1),
26 | C_CURRENT_CDEMO_SK(116, 1),
27 | C_CURRENT_HDEMO_SK(117, 1),
28 | C_CURRENT_ADDR_SK(118, 1),
29 | C_FIRST_SHIPTO_DATE_ID(119, 0),
30 | C_FIRST_SALES_DATE_ID(120, 1),
31 | C_SALUTATION(121, 1),
32 | C_FIRST_NAME(122, 1),
33 | C_LAST_NAME(123, 1),
34 | C_PREFERRED_CUST_FLAG(124, 2),
35 | C_BIRTH_DAY(125, 1),
36 | C_BIRTH_MONTH(126, 0),
37 | C_BIRTH_YEAR(127, 0),
38 | C_BIRTH_COUNTRY(128, 1),
39 | C_LOGIN(129, 1),
40 | C_EMAIL_ADDRESS(130, 23),
41 | C_LAST_REVIEW_DATE(131, 1),
42 | C_NULLS(132, 2);
43 |
44 | private final int globalColumnNumber;
45 | private final int seedsPerRow;
46 |
47 | CustomerGeneratorColumn(int globalColumnNumber, int seedsPerRow)
48 | {
49 | this.globalColumnNumber = globalColumnNumber;
50 | this.seedsPerRow = seedsPerRow;
51 | }
52 |
53 | @Override
54 | public Table getTable()
55 | {
56 | return CUSTOMER;
57 | }
58 |
59 | @Override
60 | public int getGlobalColumnNumber()
61 | {
62 | return globalColumnNumber;
63 | }
64 |
65 | @Override
66 | public int getSeedsPerRow()
67 | {
68 | return seedsPerRow;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/PromotionGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.PROMOTION;
20 |
21 | public enum PromotionGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | P_PROMO_SK(228, 1),
25 | P_PROMO_ID(229, 1),
26 | P_START_DATE_ID(230, 1),
27 | P_END_DATE_ID(231, 1),
28 | P_ITEM_SK(232, 1),
29 | P_COST(233, 1),
30 | P_RESPONSE_TARGET(234, 1),
31 | P_PROMO_NAME(235, 1),
32 | P_CHANNEL_DMAIL(236, 1),
33 | P_CHANNEL_EMAIL(237, 1),
34 | P_CHANNEL_CATALOG(238, 1),
35 | P_CHANNEL_TV(239, 1),
36 | P_CHANNEL_RADIO(240, 1),
37 | P_CHANNEL_PRESS(241, 1),
38 | P_CHANNEL_EVENT(242, 1),
39 | P_CHANNEL_DEMO(243, 1),
40 | P_CHANNEL_DETAILS(244, 100),
41 | P_PURPOSE(245, 1),
42 | P_DISCOUNT_ACTIVE(246, 1),
43 | P_NULLS(247, 2);
44 |
45 | private final int globalColumnNumber;
46 | private final int seedsPerRow;
47 |
48 | PromotionGeneratorColumn(int globalColumnNumber, int seedsPerRow)
49 | {
50 | this.globalColumnNumber = globalColumnNumber;
51 | this.seedsPerRow = seedsPerRow;
52 | }
53 |
54 | @Override
55 | public Table getTable()
56 | {
57 | return PROMOTION;
58 | }
59 |
60 | @Override
61 | public int getGlobalColumnNumber()
62 | {
63 | return globalColumnNumber;
64 | }
65 |
66 | @Override
67 | public int getSeedsPerRow()
68 | {
69 | return seedsPerRow;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/CustomerAddressColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.CUSTOMER_ADDRESS;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.character;
21 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
22 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
23 |
24 | public enum CustomerAddressColumn
25 | implements Column
26 | {
27 | CA_ADDRESS_SK(IDENTIFIER),
28 | CA_ADDRESS_ID(character(16)),
29 | CA_STREET_NUMBER(character(10)),
30 | CA_STREET_NAME(varchar(60)),
31 | CA_STREET_TYPE(character(15)),
32 | CA_SUITE_NUMBER(character(10)),
33 | CA_CITY(varchar(60)),
34 | CA_COUNTY(varchar(30)),
35 | CA_STATE(character(2)),
36 | CA_ZIP(character(10)),
37 | CA_COUNTRY(varchar(20)),
38 | CA_GMT_OFFSET(decimal(5, 2)),
39 | CA_LOCATION_TYPE(character(20));
40 |
41 | private final ColumnType type;
42 |
43 | CustomerAddressColumn(ColumnType type)
44 | {
45 | this.type = type;
46 | }
47 |
48 | @Override
49 | public Table getTable()
50 | {
51 | return CUSTOMER_ADDRESS;
52 | }
53 |
54 | @Override
55 | public String getName()
56 | {
57 | return name().toLowerCase();
58 | }
59 |
60 | @Override
61 | public ColumnType getType()
62 | {
63 | return type;
64 | }
65 |
66 | @Override
67 | public int getPosition()
68 | {
69 | return ordinal();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/Driver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | import com.google.common.collect.ImmutableList;
18 | import io.airlift.airline.Command;
19 | import io.airlift.airline.HelpOption;
20 |
21 | import javax.inject.Inject;
22 |
23 | import java.util.List;
24 |
25 | import static io.airlift.airline.SingleCommand.singleCommand;
26 |
27 | @Command(name = "dsdgen", description = "data generator for TPC-DS")
28 | public class Driver
29 | {
30 | @Inject
31 | public HelpOption helpOption;
32 |
33 | @Inject
34 | public Options options = new Options();
35 |
36 | public static void main(String[] args)
37 | {
38 | Driver driver = singleCommand(Driver.class).parse(args);
39 | driver.run();
40 | }
41 |
42 | private void run()
43 | {
44 | if (helpOption.showHelpIfRequested()) {
45 | return;
46 | }
47 |
48 | Session session = options.toSession();
49 | List tablesToGenerate;
50 | if (session.generateOnlyOneTable()) {
51 | tablesToGenerate = ImmutableList.of(session.getOnlyTableToGenerate());
52 | }
53 | else {
54 | tablesToGenerate = Table.getBaseTables();
55 | }
56 |
57 | for (int i = 1; i <= session.getParallelism(); i++) {
58 | int chunkNumber = i;
59 | new Thread(() -> {
60 | TableGenerator tableGenerator = new TableGenerator(session.withChunkNumber(chunkNumber));
61 | tablesToGenerate.forEach(tableGenerator::generateTable);
62 | }).start();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/TableRowWithNulls.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import com.teradata.tpcds.generator.GeneratorColumn;
18 |
19 | import static com.teradata.tpcds.type.Date.fromJulianDays;
20 |
21 | public abstract class TableRowWithNulls
22 | implements TableRow
23 | {
24 | private long nullBitMap;
25 | private GeneratorColumn firstColumn;
26 |
27 | protected TableRowWithNulls(long nullBitMap, GeneratorColumn firstColumn)
28 | {
29 | this.nullBitMap = nullBitMap;
30 | this.firstColumn = firstColumn;
31 | }
32 |
33 | private boolean isNull(GeneratorColumn column)
34 | {
35 | long kBitMask = 1L << (column.getGlobalColumnNumber() - firstColumn.getGlobalColumnNumber());
36 | return (nullBitMap & kBitMask) != 0;
37 | }
38 |
39 | protected String getStringOrNull(T value, GeneratorColumn column)
40 | {
41 | return isNull(column) ? null : value.toString();
42 | }
43 |
44 | protected String getStringOrNullForKey(long value, GeneratorColumn column)
45 | {
46 | return (isNull(column) || value == -1) ? null : Long.toString(value);
47 | }
48 |
49 | protected String getStringOrNullForBoolean(boolean value, GeneratorColumn column)
50 | {
51 | if (isNull(column)) {
52 | return null;
53 | }
54 |
55 | return value ? "Y" : "N";
56 | }
57 |
58 | protected String getDateStringOrNullFromJulianDays(long value, GeneratorColumn column)
59 | {
60 | return (isNull(column) || value < 0) ? null : fromJulianDays((int) value).toString();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/ItemGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.ITEM;
20 |
21 | public enum ItemGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | I_ITEM_SK(203, 1),
25 | I_ITEM_ID(204, 1),
26 | I_REC_START_DATE_ID(205, 1),
27 | I_REC_END_DATE_ID(206, 2),
28 | I_ITEM_DESC(207, 200),
29 | I_CURRENT_PRICE(208, 2),
30 | I_WHOLESALE_COST(209, 1),
31 | I_BRAND_ID(210, 1),
32 | I_BRAND(211, 1),
33 | I_CLASS_ID(212, 1),
34 | I_CLASS(213, 1),
35 | I_CATEGORY_ID(214, 1),
36 | I_CATEGORY(215, 1),
37 | I_MANUFACT_ID(216, 2),
38 | I_MANUFACT(217, 1),
39 | I_SIZE(218, 1),
40 | I_FORMULATION(219, 50),
41 | I_COLOR(220, 1),
42 | I_UNITS(221, 1),
43 | I_CONTAINER(222, 1),
44 | I_MANAGER_ID(223, 2),
45 | I_PRODUCT_NAME(224, 1),
46 | I_NULLS(225, 2),
47 | I_SCD(226, 1),
48 | I_PROMO_SK(227, 2);
49 |
50 | private final int globalColumnNumber;
51 | private final int seedsPerRow;
52 |
53 | ItemGeneratorColumn(int globalColumnNumber, int seedsPerRow)
54 | {
55 | this.globalColumnNumber = globalColumnNumber;
56 | this.seedsPerRow = seedsPerRow;
57 | }
58 |
59 | @Override
60 | public Table getTable()
61 | {
62 | return ITEM;
63 | }
64 |
65 | @Override
66 | public int getGlobalColumnNumber()
67 | {
68 | return globalColumnNumber;
69 | }
70 |
71 | @Override
72 | public int getSeedsPerRow()
73 | {
74 | return seedsPerRow;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/WebPageColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.WEB_PAGE;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
21 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
22 | import static com.teradata.tpcds.column.ColumnTypes.character;
23 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
24 |
25 | public enum WebPageColumn
26 | implements Column
27 | {
28 | WP_WEB_PAGE_SK(IDENTIFIER),
29 | WP_WEB_PAGE_ID(character(16)),
30 | WP_REC_START_DATE(DATE),
31 | WP_REC_END_DATE(DATE),
32 | WP_CREATION_DATE_SK(IDENTIFIER),
33 | WP_ACCESS_DATE_SK(IDENTIFIER),
34 | WP_AUTOGEN_FLAG(character(1)),
35 | WP_CUSTOMER_SK(IDENTIFIER),
36 | WP_URL(varchar(100)),
37 | WP_TYPE(character(50)),
38 | WP_CHAR_COUNT(INTEGER),
39 | WP_LINK_COUNT(INTEGER),
40 | WP_IMAGE_COUNT(INTEGER),
41 | WP_MAX_AD_COUNT(INTEGER);
42 |
43 | private final ColumnType type;
44 |
45 | WebPageColumn(ColumnType type)
46 | {
47 | this.type = type;
48 | }
49 |
50 | @Override
51 | public Table getTable()
52 | {
53 | return WEB_PAGE;
54 | }
55 |
56 | @Override
57 | public String getName()
58 | {
59 | return name().toLowerCase();
60 | }
61 |
62 | @Override
63 | public ColumnType getType()
64 | {
65 | return type;
66 | }
67 |
68 | @Override
69 | public int getPosition()
70 | {
71 | return ordinal();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/WarehouseColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.WAREHOUSE;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
23 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
24 |
25 | public enum WarehouseColumn
26 | implements Column
27 | {
28 | W_WAREHOUSE_SK(IDENTIFIER),
29 | W_WAREHOUSE_ID(character(16)),
30 | W_WAREHOUSE_NAME(varchar(20)),
31 | W_WAREHOUSE_SQ_FT(INTEGER),
32 | W_STREET_NUMBER(character(10)),
33 | W_STREET_NAME(varchar(60)),
34 | W_STREET_TYPE(character(15)),
35 | W_SUITE_NUMBER(character(10)),
36 | W_CITY(varchar(60)),
37 | W_COUNTY(varchar(30)),
38 | W_STATE(character(2)),
39 | W_ZIP(character(10)),
40 | W_COUNTRY(varchar(20)),
41 | W_GMT_OFFSET(decimal(5, 2));
42 |
43 | private final ColumnType type;
44 |
45 | WarehouseColumn(ColumnType type)
46 | {
47 | this.type = type;
48 | }
49 |
50 | @Override
51 | public Table getTable()
52 | {
53 | return WAREHOUSE;
54 | }
55 |
56 | @Override
57 | public String getName()
58 | {
59 | return name().toLowerCase();
60 | }
61 |
62 | @Override
63 | public ColumnType getType()
64 | {
65 | return type;
66 | }
67 |
68 | @Override
69 | public int getPosition()
70 | {
71 | return ordinal();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/TableFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds;
16 |
17 | public class TableFlags
18 | {
19 | private final boolean keepsHistory; // FL_TYPE_2 in the c code. this dimension keeps history -- rowcount shows unique entities (not including revisions).
20 | private final boolean isSmall; // this table has low rowcount; used by Address.java
21 | private final boolean isDateBased;
22 |
23 | public TableFlags(boolean keepsHistory, boolean isSmall, boolean isDateBased)
24 | {
25 | this.keepsHistory = keepsHistory;
26 | this.isSmall = isSmall;
27 | this.isDateBased = isDateBased;
28 | }
29 |
30 | public boolean keepsHistory()
31 | {
32 | return keepsHistory;
33 | }
34 |
35 | public boolean isSmall()
36 | {
37 | return isSmall;
38 | }
39 |
40 | public static class TableFlagsBuilder
41 | {
42 | private boolean keepsHistory = false;
43 | private boolean isSmall = false;
44 | private boolean isDateBased = false;
45 |
46 | public TableFlagsBuilder() {}
47 |
48 | public TableFlagsBuilder setKeepsHistory()
49 | {
50 | this.keepsHistory = true;
51 | return this;
52 | }
53 |
54 | public TableFlagsBuilder setIsSmall()
55 | {
56 | this.isSmall = true;
57 | return this;
58 | }
59 |
60 | public TableFlagsBuilder setIsDateBased()
61 | {
62 | this.isDateBased = true;
63 | return this;
64 | }
65 |
66 | public TableFlags build()
67 | {
68 | return new TableFlags(keepsHistory, isSmall, isDateBased);
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/StoreReturnsGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.STORE_RETURNS;
20 |
21 | public enum StoreReturnsGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | SR_RETURNED_DATE_SK(292, 32),
25 | SR_RETURNED_TIME_SK(293, 32),
26 | SR_ITEM_SK(294, 16),
27 | SR_CUSTOMER_SK(295, 16),
28 | SR_CDEMO_SK(296, 16),
29 | SR_HDEMO_SK(297, 16),
30 | SR_ADDR_SK(298, 16),
31 | SR_STORE_SK(299, 16),
32 | SR_REASON_SK(300, 16),
33 | SR_TICKET_NUMBER(301, 16),
34 | SR_PRICING_QUANTITY(302, 0),
35 | SR_PRICING_NET_PAID(303, 0),
36 | SR_PRICING_EXT_TAX(304, 0),
37 | SR_PRICING_NET_PAID_INC_TAX(305, 0),
38 | SR_PRICING_FEE(306, 0),
39 | SR_PRICING_EXT_SHIP_COST(307, 0),
40 | SR_PRICING_REFUNDED_CASH(308, 0),
41 | SR_PRICING_REVERSED_CHARGE(309, 0),
42 | SR_PRICING_STORE_CREDIT(310, 0),
43 | SR_PRICING_NET_LOSS(311, 0),
44 | SR_PRICING(312, 80),
45 | SR_NULLS(313, 32);
46 |
47 | private final int globalColumnNumber;
48 | private final int seedsPerRow;
49 |
50 | StoreReturnsGeneratorColumn(int globalColumnNumber, int seedsPerRow)
51 | {
52 | this.globalColumnNumber = globalColumnNumber;
53 | this.seedsPerRow = seedsPerRow;
54 | }
55 |
56 | @Override
57 | public Table getTable()
58 | {
59 | return STORE_RETURNS;
60 | }
61 |
62 | @Override
63 | public int getGlobalColumnNumber()
64 | {
65 | return globalColumnNumber;
66 | }
67 |
68 | @Override
69 | public int getSeedsPerRow()
70 | {
71 | return seedsPerRow;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/street_names.dst:
--------------------------------------------------------------------------------
1 | -- street_names
2 | -- from 1990 census
3 | -- values weights
4 | -- ========= =========
5 | -- 1. street name 1. default
6 | -- 2. returns an empty string 50% of the time
7 |
8 | : 0, 317000
9 | Church: 4031, 4031
10 | Central: 2450, 2450
11 | Center: 3402, 3402
12 | College: 2468, 2468
13 | Twelfth: 489, 489
14 | 12th: 2957, 2957
15 | South: 3570, 3570
16 | Lakeview: 2487, 2487
17 | West: 3656, 3656
18 | Miller: 2488, 2488
19 | Cherry: 3669, 3669
20 | Broadway: 2511, 2511
21 | Jackson: 3725, 3725
22 | Sycamore: 2533, 2533
23 | Elevnth: 669, 669
24 | 11th: 3109, 3109
25 | Hillcrest: 2547, 2547
26 | Railroad: 3853, 3853
27 | Fifteenth: 240, 240
28 | 15th: 2317, 2317
29 | Sunset: 3929, 3929
30 | Madison: 2578, 2578
31 | Mill: 3975, 3975
32 | Ash: 2589, 2589
33 | Willow: 4017, 2613
34 | Woodland: 2615, 2615
35 | Lincoln: 4044, 4044
36 | Locust: 2618, 2618
37 | Ridge: 4048, 4048
38 | Poplar: 2645, 2645
39 | North: 4074, 4074
40 | Green: 2652, 2652
41 | Spring: 4165, 4165
42 | Dogwood: 2653, 2653
43 | Tenth: 879, 879
44 | 10th: 3492, 3492
45 | Lee: 2669, 2669
46 | Walnut: 4799, 4799
47 | Williams: 2682, 2682
48 | Hill: 4877, 4877
49 | Birch: 2754, 2754
50 | Lake: 4901, 4901
51 | Davis: 2769, 2769
52 | 9th: 3793, 3793
53 | Ninth: 1115, 1115
54 | Laurel: 2780, 2780
55 | Washington: 4974, 4974
56 | Spruce: 2821, 2821
57 | View: 5202, 5202
58 | 14th: 2536, 2536
59 | Fourteenth: 315, 315
60 | Elm: 5233, 5233
61 | Adams: 2856, 2856
62 | 8th: 4172, 4172
63 | Eigth: 1352, 1352
64 | Franklin: 2882, 2882
65 | Cedar: 5644, 5644
66 | 13th: 2610, 2610
67 | Thirteenth: 367, 367
68 | Maple: 6103, 6103
69 | Chestnut: 2994, 2994
70 | Pine: 6170, 6170
71 | East: 3056, 3056
72 | 7th: 4635, 4635
73 | Seventh: 1742, 1742
74 | Smith: 3076, 3076
75 | Oak: 6946, 6946
76 | Valley: 3082, 3082
77 | 6th: 5097, 5097
78 | Sixth: 2186, 2186
79 | Meadow: 3193, 3193
80 | Main: 7664, 7664
81 | River: 3220, 3220
82 | 5th: 5532, 5532
83 | Fifth: 2654, 2654
84 | Wilson: 3268, 3268
85 | Park: 8926, 8926
86 | Hickory: 3297, 3297
87 | 4th: 6183, 6183
88 | Fourth: 3007, 3007
89 | Jefferson: 3306, 3306
90 | 1st: 6047, 6047
91 | First: 3851, 3851
92 | Forest: 3309, 3309
93 | 3rd: 6564, 6564
94 | Third: 3567, 3567
95 | Johnson: 3325, 3325
96 | 2nd: 6907, 6907
97 | Second: 3959, 3959
98 | Highland: 3347, 3347
99 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/DateDimGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.DATE_DIM;
20 |
21 | public enum DateDimGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | D_DATE_SK(159, 0),
25 | D_DATE_ID(160, 0),
26 | D_DATE(161, 0),
27 | D_MONTH_SEQ(162, 0),
28 | D_WEEK_SEQ(163, 0),
29 | D_QUARTER_SEQ(164, 0),
30 | D_YEAR(165, 0),
31 | D_DOW(166, 0),
32 | D_MOY(167, 0),
33 | D_DOM(168, 0),
34 | D_QOY(169, 0),
35 | D_FY_YEAR(170, 0),
36 | D_FY_QUARTER_SEQ(171, 0),
37 | D_FY_WEEK_SEQ(172, 0),
38 | D_DAY_NAME(173, 0),
39 | D_QUARTER_NAME(174, 0),
40 | D_HOLIDAY(175, 0),
41 | D_WEEKEND(176, 0),
42 | D_FOLLOWING_HOLIDAY(177, 0),
43 | D_FIRST_DOM(178, 0),
44 | D_LAST_DOM(179, 0),
45 | D_SAME_DAY_LY(180, 0),
46 | D_SAME_DAY_LQ(181, 0),
47 | D_CURRENT_DAY(182, 0),
48 | D_CURRENT_WEEK(183, 0),
49 | D_CURRENT_MONTH(184, 0),
50 | D_CURRENT_QUARTER(185, 0),
51 | D_CURRENT_YEAR(186, 0),
52 | D_NULLS(187, 2);
53 |
54 | private final int globalColumnNumber;
55 | private final int seedsPerRow;
56 |
57 | DateDimGeneratorColumn(int globalColumnNumber, int seedsPerRow)
58 | {
59 | this.globalColumnNumber = globalColumnNumber;
60 | this.seedsPerRow = seedsPerRow;
61 | }
62 |
63 | @Override
64 | public Table getTable()
65 | {
66 | return DATE_DIM;
67 | }
68 |
69 | @Override
70 | public int getGlobalColumnNumber()
71 | {
72 | return globalColumnNumber;
73 | }
74 |
75 | @Override
76 | public int getSeedsPerRow()
77 | {
78 | return seedsPerRow;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/CustomerColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.CUSTOMER;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
23 |
24 | public enum CustomerColumn
25 | implements Column
26 | {
27 | C_CUSTOMER_SK(IDENTIFIER),
28 | C_CUSTOMER_ID(character(16)),
29 | C_CURRENT_CDEMO_SK(IDENTIFIER),
30 | C_CURRENT_HDEMO_SK(IDENTIFIER),
31 | C_CURRENT_ADDR_SK(IDENTIFIER),
32 | C_FIRST_SHIPTO_DATE_SK(IDENTIFIER),
33 | C_FIRST_SALES_DATE_SK(IDENTIFIER),
34 | C_SALUTATION(character(10)),
35 | C_FIRST_NAME(character(20)),
36 | C_LAST_NAME(character(30)),
37 | C_PREFERRED_CUST_FLAG(character(1)),
38 | C_BIRTH_DAY(INTEGER),
39 | C_BIRTH_MONTH(INTEGER),
40 | C_BIRTH_YEAR(INTEGER),
41 | C_BIRTH_COUNTRY(varchar(20)),
42 | C_LOGIN(character(13)),
43 | C_EMAIL_ADDRESS(character(50)),
44 | C_LAST_REVIEW_DATE_SK(IDENTIFIER);
45 |
46 | private final ColumnType type;
47 |
48 | CustomerColumn(ColumnType type)
49 | {
50 | this.type = type;
51 | }
52 |
53 | @Override
54 | public Table getTable()
55 | {
56 | return CUSTOMER;
57 | }
58 |
59 | @Override
60 | public String getName()
61 | {
62 | return name().toLowerCase();
63 | }
64 |
65 | @Override
66 | public ColumnType getType()
67 | {
68 | return type;
69 | }
70 |
71 | @Override
72 | public int getPosition()
73 | {
74 | return ordinal();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/StoreReturnsColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.STORE_RETURNS;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
22 |
23 | public enum StoreReturnsColumn
24 | implements Column
25 | {
26 | SR_RETURNED_DATE_SK(IDENTIFIER),
27 | SR_RETURN_TIME_SK(IDENTIFIER),
28 | SR_ITEM_SK(IDENTIFIER),
29 | SR_CUSTOMER_SK(IDENTIFIER),
30 | SR_CDEMO_SK(IDENTIFIER),
31 | SR_HDEMO_SK(IDENTIFIER),
32 | SR_ADDR_SK(IDENTIFIER),
33 | SR_STORE_SK(IDENTIFIER),
34 | SR_REASON_SK(IDENTIFIER),
35 | SR_TICKET_NUMBER(IDENTIFIER),
36 | SR_RETURN_QUANTITY(INTEGER),
37 | SR_RETURN_AMT(decimal(7, 2)),
38 | SR_RETURN_TAX(decimal(7, 2)),
39 | SR_RETURN_AMT_INC_TAX(decimal(7, 2)),
40 | SR_FEE(decimal(7, 2)),
41 | SR_RETURN_SHIP_COST(decimal(7, 2)),
42 | SR_REFUNDED_CASH(decimal(7, 2)),
43 | SR_REVERSED_CHARGE(decimal(7, 2)),
44 | SR_STORE_CREDIT(decimal(7, 2)),
45 | SR_NET_LOSS(decimal(7, 2));
46 |
47 | private final ColumnType type;
48 |
49 | StoreReturnsColumn(ColumnType type)
50 | {
51 | this.type = type;
52 | }
53 |
54 | @Override
55 | public Table getTable()
56 | {
57 | return STORE_RETURNS;
58 | }
59 |
60 | @Override
61 | public String getName()
62 | {
63 | return name().toLowerCase();
64 | }
65 |
66 | @Override
67 | public ColumnType getType()
68 | {
69 | return type;
70 | }
71 |
72 | @Override
73 | public int getPosition()
74 | {
75 | return ordinal();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/PromotionColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.PROMOTION;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.character;
22 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
23 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
24 |
25 | public enum PromotionColumn
26 | implements Column
27 | {
28 | P_PROMO_SK(IDENTIFIER),
29 | P_PROMO_ID(character(16)),
30 | P_START_DATE_SK(IDENTIFIER),
31 | P_END_DATE_SK(IDENTIFIER),
32 | P_ITEM_SK(IDENTIFIER),
33 | P_COST(decimal(15, 2)),
34 | P_RESPONSE_TARGE(INTEGER),
35 | P_PROMO_NAME(character(50)),
36 | P_CHANNEL_DMAIL(character(1)),
37 | P_CHANNEL_EMAIL(character(1)),
38 | P_CHANNEL_CATALOG(character(1)),
39 | P_CHANNEL_TV(character(1)),
40 | P_CHANNEL_RADIO(character(1)),
41 | P_CHANNEL_PRESS(character(1)),
42 | P_CHANNEL_EVENT(character(1)),
43 | P_CHANNEL_DEMO(character(1)),
44 | P_CHANNEL_DETAILS(varchar(100)),
45 | P_PURPOSE(character(15)),
46 | P_DISCOUNT_ACTIVE(character(1));
47 |
48 | private final ColumnType type;
49 |
50 | PromotionColumn(ColumnType type)
51 | {
52 | this.type = type;
53 | }
54 |
55 | @Override
56 | public Table getTable()
57 | {
58 | return PROMOTION;
59 | }
60 |
61 | @Override
62 | public String getName()
63 | {
64 | return name().toLowerCase();
65 | }
66 |
67 | @Override
68 | public ColumnType getType()
69 | {
70 | return type;
71 | }
72 |
73 | @Override
74 | public int getPosition()
75 | {
76 | return ordinal();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/HouseholdDemographicsRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import java.util.List;
18 |
19 | import static com.google.common.collect.Lists.newArrayList;
20 | import static com.teradata.tpcds.generator.HouseholdDemographicsGeneratorColumn.HD_BUY_POTENTIAL;
21 | import static com.teradata.tpcds.generator.HouseholdDemographicsGeneratorColumn.HD_DEMO_SK;
22 | import static com.teradata.tpcds.generator.HouseholdDemographicsGeneratorColumn.HD_DEP_COUNT;
23 | import static com.teradata.tpcds.generator.HouseholdDemographicsGeneratorColumn.HD_INCOME_BAND_ID;
24 | import static com.teradata.tpcds.generator.HouseholdDemographicsGeneratorColumn.HD_VEHICLE_COUNT;
25 |
26 | public class HouseholdDemographicsRow
27 | extends TableRowWithNulls
28 | {
29 | private final long hdDemoSk;
30 | private final long hdIncomeBandId;
31 | private final String hdBuyPotential;
32 | private final int hdDepCount;
33 | private final int hdVehicleCount;
34 |
35 | public HouseholdDemographicsRow(long nullBitMap, long hdDemoSk, long hdIncomeBandId, String hdBuyPotential, int hdDepCount, int hdVehicleCount)
36 | {
37 | super(nullBitMap, HD_DEMO_SK);
38 | this.hdDemoSk = hdDemoSk;
39 | this.hdIncomeBandId = hdIncomeBandId;
40 | this.hdBuyPotential = hdBuyPotential;
41 | this.hdDepCount = hdDepCount;
42 | this.hdVehicleCount = hdVehicleCount;
43 | }
44 |
45 | @Override
46 | public List getValues()
47 | {
48 | return newArrayList(getStringOrNullForKey(hdDemoSk, HD_DEMO_SK),
49 | getStringOrNullForKey(hdIncomeBandId, HD_INCOME_BAND_ID),
50 | getStringOrNull(hdBuyPotential, HD_BUY_POTENTIAL),
51 | getStringOrNull(hdDepCount, HD_DEP_COUNT),
52 | getStringOrNull(hdVehicleCount, HD_VEHICLE_COUNT));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/TimeDimRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.distribution.HoursDistribution.HourInfo;
19 | import com.teradata.tpcds.row.TimeDimRow;
20 |
21 | import static com.teradata.tpcds.BusinessKeyGenerator.makeBusinessKey;
22 | import static com.teradata.tpcds.Nulls.createNullBitMap;
23 | import static com.teradata.tpcds.Table.TIME_DIM;
24 | import static com.teradata.tpcds.distribution.HoursDistribution.getHourInfoForHour;
25 | import static com.teradata.tpcds.generator.TimeDimGeneratorColumn.T_NULLS;
26 |
27 | public class TimeDimRowGenerator
28 | extends AbstractRowGenerator
29 | {
30 | public TimeDimRowGenerator()
31 | {
32 | super(TIME_DIM);
33 | }
34 |
35 | @Override
36 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
37 | {
38 | long nullBitMap = createNullBitMap(TIME_DIM, getRandomNumberStream(T_NULLS));
39 | long tTimeSk = rowNumber - 1;
40 | String tTimeId = makeBusinessKey(rowNumber);
41 | int tTime = (int) (rowNumber - 1);
42 | long timeTemp = tTime;
43 | int tSecond = (int) (timeTemp % 60);
44 | timeTemp /= 60;
45 | int tMinute = (int) (timeTemp % 60);
46 | timeTemp /= 60;
47 | int tHour = (int) (timeTemp % 24);
48 |
49 | HourInfo hourInfo = getHourInfoForHour(tHour);
50 | String tAmPm = hourInfo.getAmPm();
51 | String tShift = hourInfo.getShift();
52 | String tSubShift = hourInfo.getSubShift();
53 | String tMealTime = hourInfo.getMeal();
54 |
55 | return new RowGeneratorResult(new TimeDimRow(nullBitMap, tTimeSk, tTimeId, tTime, tHour, tMinute, tSecond, tAmPm, tShift, tSubShift, tMealTime));
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/StoreSalesGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.STORE_SALES;
20 |
21 | public enum StoreSalesGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | SS_SOLD_DATE_SK(314, 2),
25 | SS_SOLD_TIME_SK(315, 2),
26 | SS_SOLD_ITEM_SK(316, 1),
27 | SS_SOLD_CUSTOMER_SK(317, 1),
28 | SS_SOLD_CDEMO_SK(318, 1),
29 | SS_SOLD_HDEMO_SK(319, 1),
30 | SS_SOLD_ADDR_SK(320, 1),
31 | SS_SOLD_STORE_SK(321, 1),
32 | SS_SOLD_PROMO_SK(322, 16),
33 | SS_TICKET_NUMBER(323, 1),
34 | SS_PRICING_QUANTITY(324, 1),
35 | SS_PRICING_WHOLESALE_COST(325, 0),
36 | SS_PRICING_LIST_PRICE(326, 0),
37 | SS_PRICING_SALES_PRICE(327, 0),
38 | SS_PRICING_COUPON_AMT(328, 0),
39 | SS_PRICING_EXT_SALES_PRICE(329, 0),
40 | SS_PRICING_EXT_WHOLESALE_COST(330, 0),
41 | SS_PRICING_EXT_LIST_PRICE(331, 0),
42 | SS_PRICING_EXT_TAX(332, 0),
43 | SS_PRICING_NET_PAID(333, 0),
44 | SS_PRICING_NET_PAID_INC_TAX(334, 0),
45 | SS_PRICING_NET_PROFIT(335, 0),
46 | SR_IS_RETURNED(336, 16),
47 | SS_PRICING(337, 128),
48 | SS_NULLS(338, 32),
49 | SS_PERMUTATION(339, 0);
50 |
51 | private final int globalColumnNumber;
52 | private final int seedsPerRow;
53 |
54 | StoreSalesGeneratorColumn(int globalColumnNumber, int seedsPerRow)
55 | {
56 | this.globalColumnNumber = globalColumnNumber;
57 | this.seedsPerRow = seedsPerRow;
58 | }
59 |
60 | @Override
61 | public Table getTable()
62 | {
63 | return STORE_SALES;
64 | }
65 |
66 | @Override
67 | public int getGlobalColumnNumber()
68 | {
69 | return globalColumnNumber;
70 | }
71 |
72 | @Override
73 | public int getSeedsPerRow()
74 | {
75 | return seedsPerRow;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/StoreSalesColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.STORE_SALES;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
22 |
23 | public enum StoreSalesColumn
24 | implements Column
25 | {
26 | SS_SOLD_DATE_SK(IDENTIFIER),
27 | SS_SOLD_TIME_SK(IDENTIFIER),
28 | SS_ITEM_SK(IDENTIFIER),
29 | SS_CUSTOMER_SK(IDENTIFIER),
30 | SS_CDEMO_SK(IDENTIFIER),
31 | SS_HDEMO_SK(IDENTIFIER),
32 | SS_ADDR_SK(IDENTIFIER),
33 | SS_STORE_SK(IDENTIFIER),
34 | SS_PROMO_SK(IDENTIFIER),
35 | SS_TICKET_NUMBER(IDENTIFIER),
36 | SS_QUANTITY(INTEGER),
37 | SS_WHOLESALE_COST(decimal(7, 2)),
38 | SS_LIST_PRICE(decimal(7, 2)),
39 | SS_SALES_PRICE(decimal(7, 2)),
40 | SS_EXT_DISCOUNT_AMT(decimal(7, 2)),
41 | SS_EXT_SALES_PRICE(decimal(7, 2)),
42 | SS_EXT_WHOLESALE_COST(decimal(7, 2)),
43 | SS_EXT_LIST_PRICE(decimal(7, 2)),
44 | SS_EXT_TAX(decimal(7, 2)),
45 | SS_COUPON_AMT(decimal(7, 2)),
46 | SS_NET_PAID(decimal(7, 2)),
47 | SS_NET_PAID_INC_TAX(decimal(7, 2)),
48 | SS_NET_PROFIT(decimal(7, 2));
49 |
50 | private final ColumnType type;
51 |
52 | StoreSalesColumn(ColumnType type)
53 | {
54 | this.type = type;
55 | }
56 |
57 | @Override
58 | public Table getTable()
59 | {
60 | return STORE_SALES;
61 | }
62 |
63 | @Override
64 | public String getName()
65 | {
66 | return name().toLowerCase();
67 | }
68 |
69 | @Override
70 | public ColumnType getType()
71 | {
72 | return type;
73 | }
74 |
75 | @Override
76 | public int getPosition()
77 | {
78 | return ordinal();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/WebSiteGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.WEB_SITE;
20 |
21 | public enum WebSiteGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | WEB_SITE_SK(447, 1),
25 | WEB_SITE_ID(448, 1),
26 | WEB_REC_START_DATE_ID(449, 1),
27 | WEB_REC_END_DATE_ID(450, 1),
28 | WEB_NAME(451, 1),
29 | WEB_OPEN_DATE(452, 1),
30 | WEB_CLOSE_DATE(453, 1),
31 | WEB_CLASS(454, 1),
32 | WEB_MANAGER(455, 2),
33 | WEB_MARKET_ID(456, 1),
34 | WEB_MARKET_CLASS(457, 20),
35 | WEB_MARKET_DESC(458, 100),
36 | WEB_MARKET_MANAGER(459, 2),
37 | WEB_COMPANY_ID(460, 1),
38 | WEB_COMPANY_NAME(461, 1),
39 | WEB_ADDRESS_STREET_NUM(462, 1),
40 | WEB_ADDRESS_STREET_NAME1(463, 1),
41 | WEB_ADDRESS_STREET_TYPE(464, 1),
42 | WEB_ADDRESS_SUITE_NUM(465, 1),
43 | WEB_ADDRESS_CITY(466, 1),
44 | WEB_ADDRESS_COUNTY(467, 1),
45 | WEB_ADDRESS_STATE(468, 1),
46 | WEB_ADDRESS_ZIP(469, 1),
47 | WEB_ADDRESS_COUNTRY(470, 1),
48 | WEB_ADDRESS_GMT_OFFSET(471, 1),
49 | WEB_TAX_PERCENTAGE(472, 1),
50 | WEB_NULLS(473, 2),
51 | WEB_ADDRESS(474, 7),
52 | WEB_SCD(475, 70);
53 |
54 | private final int globalColumnNumber;
55 | private final int seedsPerRow;
56 |
57 | WebSiteGeneratorColumn(int globalColumnNumber, int seedsPerRow)
58 | {
59 | this.globalColumnNumber = globalColumnNumber;
60 | this.seedsPerRow = seedsPerRow;
61 | }
62 |
63 | @Override
64 | public Table getTable()
65 | {
66 | return WEB_SITE;
67 | }
68 |
69 | @Override
70 | public int getGlobalColumnNumber()
71 | {
72 | return globalColumnNumber;
73 | }
74 |
75 | @Override
76 | public int getSeedsPerRow()
77 | {
78 | return seedsPerRow;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/WebReturnsGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.WEB_RETURNS;
20 |
21 | public enum WebReturnsGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | WR_RETURNED_DATE_SK(383, 32),
25 | WR_RETURNED_TIME_SK(384, 32),
26 | WR_ITEM_SK(385, 16),
27 | WR_REFUNDED_CUSTOMER_SK(386, 16),
28 | WR_REFUNDED_CDEMO_SK(387, 16),
29 | WR_REFUNDED_HDEMO_SK(388, 16),
30 | WR_REFUNDED_ADDR_SK(389, 16),
31 | WR_RETURNING_CUSTOMER_SK(390, 16),
32 | WR_RETURNING_CDEMO_SK(391, 16),
33 | WR_RETURNING_HDEMO_SK(392, 16),
34 | WR_RETURNING_ADDR_SK(393, 16),
35 | WR_WEB_PAGE_SK(394, 16),
36 | WR_REASON_SK(395, 16),
37 | WR_ORDER_NUMBER(396, 0),
38 | WR_PRICING_QUANTITY(397, 0),
39 | WR_PRICING_NET_PAID(398, 0),
40 | WR_PRICING_EXT_TAX(399, 0),
41 | WR_PRICING_NET_PAID_INC_TAX(400, 0),
42 | WR_PRICING_FEE(401, 0),
43 | WR_PRICING_EXT_SHIP_COST(402, 0),
44 | WR_PRICING_REFUNDED_CASH(403, 0),
45 | WR_PRICING_REVERSED_CHARGE(404, 0),
46 | WR_PRICING_STORE_CREDIT(405, 0),
47 | WR_PRICING_NET_LOSS(406, 0),
48 | WR_PRICING(407, 80),
49 | WR_NULLS(408, 32);
50 |
51 | private final int globalColumnNumber;
52 | private final int seedsPerRow;
53 |
54 | WebReturnsGeneratorColumn(int globalColumnNumber, int seedsPerRow)
55 | {
56 | this.globalColumnNumber = globalColumnNumber;
57 | this.seedsPerRow = seedsPerRow;
58 | }
59 |
60 | @Override
61 | public Table getTable()
62 | {
63 | return WEB_RETURNS;
64 | }
65 |
66 | @Override
67 | public int getGlobalColumnNumber()
68 | {
69 | return globalColumnNumber;
70 | }
71 |
72 | @Override
73 | public int getSeedsPerRow()
74 | {
75 | return seedsPerRow;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/ShipModeRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row;
16 |
17 | import java.util.List;
18 |
19 | import static com.google.common.collect.Lists.newArrayList;
20 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_CARRIER;
21 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_CODE;
22 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_CONTRACT;
23 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_SHIP_MODE_ID;
24 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_SHIP_MODE_SK;
25 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_TYPE;
26 |
27 | public class ShipModeRow
28 | extends TableRowWithNulls
29 | {
30 | private final long smShipModeSk;
31 | private final String smShipModeId;
32 | private final String smType;
33 | private final String smCode;
34 | private final String smCarrier;
35 | private final String smContract;
36 |
37 | public ShipModeRow(long nullBitMap, long smShipModeSk, String smShipModeId, String smType, String smCode, String smCarrier, String smContract)
38 | {
39 | super(nullBitMap, SM_SHIP_MODE_SK);
40 | this.smShipModeSk = smShipModeSk;
41 | this.smShipModeId = smShipModeId;
42 | this.smType = smType;
43 | this.smCode = smCode;
44 | this.smCarrier = smCarrier;
45 | this.smContract = smContract;
46 | }
47 |
48 | @Override
49 | public List getValues()
50 | {
51 | return newArrayList(getStringOrNullForKey(smShipModeSk, SM_SHIP_MODE_SK),
52 | getStringOrNull(smShipModeId, SM_SHIP_MODE_ID),
53 | getStringOrNull(smType, SM_TYPE),
54 | getStringOrNull(smCode, SM_CODE),
55 | getStringOrNull(smCarrier, SM_CARRIER),
56 | getStringOrNull(smContract, SM_CONTRACT));
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/CustomerAddressRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.row.CustomerAddressRow;
19 | import com.teradata.tpcds.type.Address;
20 |
21 | import static com.teradata.tpcds.BusinessKeyGenerator.makeBusinessKey;
22 | import static com.teradata.tpcds.Nulls.createNullBitMap;
23 | import static com.teradata.tpcds.Table.CUSTOMER_ADDRESS;
24 | import static com.teradata.tpcds.distribution.LocationTypesDistribution.LocationTypeWeights.UNIFORM;
25 | import static com.teradata.tpcds.distribution.LocationTypesDistribution.pickRandomLocationType;
26 | import static com.teradata.tpcds.generator.CustomerAddressGeneratorColumn.CA_ADDRESS;
27 | import static com.teradata.tpcds.generator.CustomerAddressGeneratorColumn.CA_LOCATION_TYPE;
28 | import static com.teradata.tpcds.generator.CustomerAddressGeneratorColumn.CA_NULLS;
29 | import static com.teradata.tpcds.type.Address.makeAddressForColumn;
30 |
31 | public class CustomerAddressRowGenerator
32 | extends AbstractRowGenerator
33 | {
34 | public CustomerAddressRowGenerator()
35 | {
36 | super(CUSTOMER_ADDRESS);
37 | }
38 |
39 | @Override
40 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
41 | {
42 | long nullBitMap = createNullBitMap(CUSTOMER_ADDRESS, getRandomNumberStream(CA_NULLS));
43 | long caAddrSk = rowNumber;
44 | String caAddrId = makeBusinessKey(rowNumber);
45 | Address caAddr = makeAddressForColumn(CUSTOMER_ADDRESS, getRandomNumberStream(CA_ADDRESS), session.getScaling());
46 | String caLocationType = pickRandomLocationType(getRandomNumberStream(CA_LOCATION_TYPE), UNIFORM);
47 | return new RowGeneratorResult(new CustomerAddressRow(nullBitMap, caAddrSk, caAddrId, caAddr, caLocationType));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/ItemColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.ITEM;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
21 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
22 | import static com.teradata.tpcds.column.ColumnTypes.character;
23 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
24 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
25 |
26 | public enum ItemColumn
27 | implements Column
28 | {
29 | I_ITEM_SK(IDENTIFIER),
30 | I_ITEM_ID(character(16)),
31 | I_REC_START_DATE(DATE),
32 | I_REC_END_DATE(DATE),
33 | I_ITEM_DESC(varchar(200)),
34 | I_CURRENT_PRICE(decimal(7, 2)),
35 | I_WHOLESALE_COST(decimal(7, 2)),
36 | I_BRAND_ID(INTEGER),
37 | I_BRAND(character(50)),
38 | I_CLASS_ID(INTEGER),
39 | I_CLASS(character(50)),
40 | I_CATEGORY_ID(INTEGER),
41 | I_CATEGORY(character(50)),
42 | I_MANUFACT_ID(INTEGER),
43 | I_MANUFACT(character(50)),
44 | I_SIZE(character(20)),
45 | I_FORMULATION(character(20)),
46 | I_COLOR(character(20)),
47 | I_UNITS(character(10)),
48 | I_CONTAINER(character(10)),
49 | I_MANAGER_ID(INTEGER),
50 | I_PRODUCT_NAME(character(50));
51 |
52 | private final ColumnType type;
53 |
54 | ItemColumn(ColumnType type)
55 | {
56 | this.type = type;
57 | }
58 |
59 | @Override
60 | public Table getTable()
61 | {
62 | return ITEM;
63 | }
64 |
65 | @Override
66 | public String getName()
67 | {
68 | return name().toLowerCase();
69 | }
70 |
71 | @Override
72 | public ColumnType getType()
73 | {
74 | return type;
75 | }
76 |
77 | @Override
78 | public int getPosition()
79 | {
80 | return ordinal();
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/CallCenterGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.CALL_CENTER;
20 |
21 | public enum CallCenterGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | CC_CALL_CENTER_SK(1, 0),
25 | CC_CALL_CENTER_ID(2, 15),
26 | CC_REC_START_DATE_ID(3, 10),
27 | CC_REC_END_DATE_ID(4, 1),
28 | CC_CLOSED_DATE_ID(5, 4),
29 | CC_OPEN_DATE_ID(6, 10),
30 | CC_NAME(7, 0),
31 | CC_CLASS(8, 2),
32 | CC_EMPLOYEES(9, 1),
33 | CC_SQ_FT(10, 1),
34 | CC_HOURS(11, 1),
35 | CC_MANAGER(12, 2),
36 | CC_MARKET_ID(13, 1),
37 | CC_MARKET_CLASS(14, 50),
38 | CC_MARKET_DESC(15, 50),
39 | CC_MARKET_MANAGER(16, 2),
40 | CC_DIVISION(17, 2),
41 | CC_DIVISION_NAME(18, 2),
42 | CC_COMPANY(19, 2),
43 | CC_COMPANY_NAME(20, 2),
44 | CC_STREET_NUMBER(21, 0),
45 | CC_STREET_NAME(22, 0),
46 | CC_STREET_TYPE(23, 0),
47 | CC_SUITE_NUMBER(24, 0),
48 | CC_CITY(25, 0),
49 | CC_COUNTY(26, 0),
50 | CC_STATE(27, 0),
51 | CC_ZIP(28, 0),
52 | CC_COUNTRY(29, 0),
53 | CC_GMT_OFFSET(30, 0),
54 | CC_ADDRESS(31, 15),
55 | CC_TAX_PERCENTAGE(32, 1),
56 | CC_SCD(33, 1),
57 | CC_NULLS(34, 2);
58 |
59 | private final int globalColumnNumber;
60 | private final int seedsPerRow;
61 |
62 | CallCenterGeneratorColumn(int globalColumnNumber, int seedsPerRow)
63 | {
64 | this.globalColumnNumber = globalColumnNumber;
65 | this.seedsPerRow = seedsPerRow;
66 | }
67 |
68 | @Override
69 | public Table getTable()
70 | {
71 | return CALL_CENTER;
72 | }
73 |
74 | @Override
75 | public int getGlobalColumnNumber()
76 | {
77 | return globalColumnNumber;
78 | }
79 |
80 | @Override
81 | public int getSeedsPerRow()
82 | {
83 | return seedsPerRow;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/sentences.dst:
--------------------------------------------------------------------------------
1 | -- sentences.dst sentence forms
2 | -- A = article
3 | -- D = adverb
4 | -- J = adjective
5 | -- N = noun
6 | -- P = preposition
7 | -- T = terminator
8 | -- V = verb
9 | -- X = auxiliary
10 | -- values weights
11 | -- ========= =========
12 | -- 1. sentence form 1. uniform
13 | ------
14 | N VT: 1
15 | J N VT: 1
16 | J\, J N VT: 1
17 | D J N VT: 1
18 | N X VT: 1
19 | J N X VT: 1
20 | J\, J N X VT: 1
21 | D J N X VT: 1
22 | N V DT: 1
23 | J N V DT: 1
24 | J\, J N V DT: 1
25 | D J N V DT: 1
26 | N X V DT: 1
27 | J N X V DT: 1
28 | J\, J N X V DT: 1
29 | D J N X V DT: 1
30 | N V P A NT: 1
31 | J N V P A NT: 1
32 | J\, J N V P A NT: 1
33 | D J N V P A NT: 1
34 | N X V P A NT: 1
35 | J N X V P A NT: 1
36 | J\, J N X V P A NT: 1
37 | D J N X V P A NT: 1
38 | N V D P A NT: 1
39 | J N V D P A NT: 1
40 | J\, J N V D P A NT: 1
41 | D J N V D P A NT: 1
42 | N X V D P A NT: 1
43 | J N X V D P A NT: 1
44 | J\, J N X V D P A NT: 1
45 | D J N X V D P A NT: 1
46 | N V NT: 1
47 | J N V NT: 1
48 | J\, J N V NT: 1
49 | D J N V NT: 1
50 | N X V NT: 1
51 | J N X V NT: 1
52 | J\, J N X V NT: 1
53 | D J N X V NT: 1
54 | N V D NT: 1
55 | J N V D NT: 1
56 | J\, J N V D NT: 1
57 | D J N V D NT: 1
58 | N X V D NT: 1
59 | J N X V D NT: 1
60 | J\, J N X V D NT: 1
61 | D J N X V D NT: 1
62 | N V J NT: 1
63 | J N V J NT: 1
64 | J\, J N V J NT: 1
65 | D J N V J NT: 1
66 | N X V J NT: 1
67 | J N X V J NT: 1
68 | J\, J N X V J NT: 1
69 | D J N X V J NT: 1
70 | N V D J NT: 1
71 | J N V D J NT: 1
72 | J\, J N V D J NT: 1
73 | D J N V D J NT: 1
74 | N X V D J NT: 1
75 | J N X V D J NT: 1
76 | J\, J N X V D J NT: 1
77 | D J N X V D J J NT: 1
78 | N V J\, J NT: 1
79 | J N V J\, J NT: 1
80 | J\, J N V J\, J NT: 1
81 | D J N V J\, J NT: 1
82 | N X V J\, J NT: 1
83 | J N X V J\, J NT: 1
84 | J\, J N X V J\, J NT: 1
85 | D J N X V J\, J NT: 1
86 | N V D J\, J NT: 1
87 | J N V D J\, J NT: 1
88 | J\, J N V D J\, J NT: 1
89 | D J N V D J\, J NT: 1
90 | N X V D J\, J NT: 1
91 | J N X V D J\, J NT: 1
92 | J\, J N X V D J\, J NT: 1
93 | D J N X V D J\, J NT: 1
94 | N V D J NT: 1
95 | J N V D J NT: 1
96 | J\, J N V D J NT: 1
97 | D J N V D J NT: 1
98 | N X V D J NT: 1
99 | J N X V D J NT: 1
100 | J\, J N X V D J NT: 1
101 | D J N X V D J NT: 1
102 | N V D D J NT: 1
103 | J N V D D J NT: 1
104 | J\, J N V D D J NT: 1
105 | D J N V D D J NT: 1
106 | N X V D D J NT: 1
107 | J N X V D D J NT: 1
108 | J\, J N X V D D J NT: 1
109 | D J N X V D D J NT: 1
110 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/WebReturnsColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
19 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
20 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
21 |
22 | public enum WebReturnsColumn
23 | implements Column
24 | {
25 | WR_RETURNED_DATE_SK(IDENTIFIER),
26 | WR_RETURNED_TIME_SK(IDENTIFIER),
27 | WR_ITEM_SK(IDENTIFIER),
28 | WR_REFUNDED_CUSTOMER_SK(IDENTIFIER),
29 | WR_REFUNDED_CDEMO_SK(IDENTIFIER),
30 | WR_REFUNDED_HDEMO_SK(IDENTIFIER),
31 | WR_REFUNDED_ADDR_SK(IDENTIFIER),
32 | WR_RETURNING_CUSTOMER_SK(IDENTIFIER),
33 | WR_RETURNING_CDEMO_SK(IDENTIFIER),
34 | WR_RETURNING_HDEMO_SK(IDENTIFIER),
35 | WR_RETURNING_ADDR_SK(IDENTIFIER),
36 | WR_WEB_PAGE_SK(IDENTIFIER),
37 | WR_REASON_SK(IDENTIFIER),
38 | WR_ORDER_NUMBER(IDENTIFIER),
39 | WR_RETURN_QUANTITY(INTEGER),
40 | WR_RETURN_AMT(decimal(7, 2)),
41 | WR_RETURN_TAX(decimal(7, 2)),
42 | WR_RETURN_AMT_INC_TAX(decimal(7, 2)),
43 | WR_FEE(decimal(7, 2)),
44 | WR_RETURN_SHIP_COST(decimal(7, 2)),
45 | WR_REFUNDED_CASH(decimal(7, 2)),
46 | WR_REVERSED_CHARGE(decimal(7, 2)),
47 | WR_ACCOUNT_CREDIT(decimal(7, 2)),
48 | WR_NET_LOSS(decimal(7, 2));
49 |
50 | private final ColumnType type;
51 |
52 | WebReturnsColumn(ColumnType type)
53 | {
54 | this.type = type;
55 | }
56 |
57 | @Override
58 | public Table getTable()
59 | {
60 | return Table.WEB_RETURNS;
61 | }
62 |
63 | @Override
64 | public String getName()
65 | {
66 | return name().toLowerCase();
67 | }
68 |
69 | @Override
70 | public ColumnType getType()
71 | {
72 | return type;
73 | }
74 |
75 | @Override
76 | public int getPosition()
77 | {
78 | return ordinal();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/DateDimColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.DATE_DIM;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
21 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
22 | import static com.teradata.tpcds.column.ColumnTypes.character;
23 |
24 | public enum DateDimColumn
25 | implements Column
26 | {
27 | D_DATE_SK(IDENTIFIER),
28 | D_DATE_ID(character(16)),
29 | D_DATE(DATE),
30 | D_MONTH_SEQ(INTEGER),
31 | D_WEEK_SEQ(INTEGER),
32 | D_QUARTER_SEQ(INTEGER),
33 | D_YEAR(INTEGER),
34 | D_DOW(INTEGER),
35 | D_MOY(INTEGER),
36 | D_DOM(INTEGER),
37 | D_QOY(INTEGER),
38 | D_FY_YEAR(INTEGER),
39 | D_FY_QUARTER_SEQ(INTEGER),
40 | D_FY_WEEK_SEQ(INTEGER),
41 | D_DAY_NAME(character(9)),
42 | D_QUARTER_NAME(character(6)),
43 | D_HOLIDAY(character(1)),
44 | D_WEEKEND(character(1)),
45 | D_FOLLOWING_HOLIDAY(character(1)),
46 | D_FIRST_DOM(INTEGER),
47 | D_LAST_DOM(INTEGER),
48 | D_SAME_DAY_LY(INTEGER),
49 | D_SAME_DAY_LQ(INTEGER),
50 | D_CURRENT_DAY(character(1)),
51 | D_CURRENT_WEEK(character(1)),
52 | D_CURRENT_MONTH(character(1)),
53 | D_CURRENT_QUARTER(character(1)),
54 | D_CURRENT_YEAR(character(1));
55 |
56 | private final ColumnType type;
57 |
58 | DateDimColumn(ColumnType type)
59 | {
60 | this.type = type;
61 | }
62 |
63 | @Override
64 | public Table getTable()
65 | {
66 | return DATE_DIM;
67 | }
68 |
69 | @Override
70 | public String getName()
71 | {
72 | return name().toLowerCase();
73 | }
74 |
75 | @Override
76 | public ColumnType getType()
77 | {
78 | return type;
79 | }
80 |
81 | @Override
82 | public int getPosition()
83 | {
84 | return ordinal();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/AbstractRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.google.common.collect.ImmutableMap;
18 | import com.teradata.tpcds.Table;
19 | import com.teradata.tpcds.generator.GeneratorColumn;
20 | import com.teradata.tpcds.random.RandomNumberStream;
21 | import com.teradata.tpcds.random.RandomNumberStreamImpl;
22 |
23 | import static com.teradata.tpcds.random.RandomValueGenerator.generateUniformRandomInt;
24 |
25 | public abstract class AbstractRowGenerator
26 | implements RowGenerator
27 | {
28 | private final ImmutableMap randomNumberStreamMap;
29 |
30 | public AbstractRowGenerator(Table table)
31 | {
32 | ImmutableMap.Builder mapBuilder = ImmutableMap.builder();
33 | for (GeneratorColumn column : table.getGeneratorColumns()) {
34 | mapBuilder.put(column, new RandomNumberStreamImpl(column.getGlobalColumnNumber(), column.getSeedsPerRow()));
35 | }
36 | randomNumberStreamMap = mapBuilder.build();
37 | }
38 |
39 | @Override
40 | public void consumeRemainingSeedsForRow()
41 | {
42 | for (RandomNumberStream randomNumberStream : randomNumberStreamMap.values()) {
43 | while (randomNumberStream.getSeedsUsed() < randomNumberStream.getSeedsPerRow()) {
44 | generateUniformRandomInt(1, 100, randomNumberStream);
45 | }
46 | randomNumberStream.resetSeedsUsed();
47 | }
48 | }
49 |
50 | public void skipRowsUntilStartingRowNumber(long startingRowNumber)
51 | {
52 | for (RandomNumberStream randomNumberStream : randomNumberStreamMap.values()) {
53 | randomNumberStream.skipRows((int) startingRowNumber - 1); // casting long to int copies C code
54 | }
55 | }
56 |
57 | public RandomNumberStream getRandomNumberStream(GeneratorColumn column)
58 | {
59 | return randomNumberStreamMap.get(column);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/WarehouseRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.row.WarehouseRow;
19 | import com.teradata.tpcds.type.Address;
20 |
21 | import static com.teradata.tpcds.BusinessKeyGenerator.makeBusinessKey;
22 | import static com.teradata.tpcds.Nulls.createNullBitMap;
23 | import static com.teradata.tpcds.Table.WAREHOUSE;
24 | import static com.teradata.tpcds.generator.WarehouseGeneratorColumn.W_NULLS;
25 | import static com.teradata.tpcds.generator.WarehouseGeneratorColumn.W_WAREHOUSE_ADDRESS;
26 | import static com.teradata.tpcds.generator.WarehouseGeneratorColumn.W_WAREHOUSE_NAME;
27 | import static com.teradata.tpcds.generator.WarehouseGeneratorColumn.W_WAREHOUSE_SQ_FT;
28 | import static com.teradata.tpcds.random.RandomValueGenerator.generateRandomText;
29 | import static com.teradata.tpcds.random.RandomValueGenerator.generateUniformRandomInt;
30 | import static com.teradata.tpcds.type.Address.makeAddressForColumn;
31 |
32 | public class WarehouseRowGenerator
33 | extends AbstractRowGenerator
34 | {
35 | public WarehouseRowGenerator()
36 | {
37 | super(WAREHOUSE);
38 | }
39 |
40 | @Override
41 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
42 | {
43 | long nullBitMap = createNullBitMap(WAREHOUSE, getRandomNumberStream(W_NULLS));
44 | long wWarehouseSk = rowNumber;
45 | String wWarehouseId = makeBusinessKey(rowNumber);
46 | String wWarehouseName = generateRandomText(10, 20, getRandomNumberStream(W_WAREHOUSE_NAME));
47 | int wWarehouseSqFt = generateUniformRandomInt(50000, 1000000, getRandomNumberStream(W_WAREHOUSE_SQ_FT));
48 | Address wAddress = makeAddressForColumn(WAREHOUSE, getRandomNumberStream(W_WAREHOUSE_ADDRESS), session.getScaling());
49 |
50 | return new RowGeneratorResult(new WarehouseRow(nullBitMap, wWarehouseSk, wWarehouseId, wWarehouseName, wWarehouseSqFt, wAddress));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/CatalogReturnsColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.CATALOG_RETURNS;
19 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
20 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
21 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
22 |
23 | public enum CatalogReturnsColumn
24 | implements Column
25 | {
26 | CR_RETURNED_DATE_SK(IDENTIFIER),
27 | CR_RETURNED_TIME_SK(IDENTIFIER),
28 | CR_ITEM_SK(IDENTIFIER),
29 | CR_REFUNDED_CUSTOMER_SK(IDENTIFIER),
30 | CR_REFUNDED_CDEMO_SK(IDENTIFIER),
31 | CR_REFUNDED_HDEMO_SK(IDENTIFIER),
32 | CR_REFUNDED_ADDR_SK(IDENTIFIER),
33 | CR_RETURNING_CUSTOMER_SK(IDENTIFIER),
34 | CR_RETURNING_CDEMO_SK(IDENTIFIER),
35 | CR_RETURNING_HDEMO_SK(IDENTIFIER),
36 | CR_RETURNING_ADDR_SK(IDENTIFIER),
37 | CR_CALL_CENTER_SK(IDENTIFIER),
38 | CR_CATALOG_PAGE_SK(IDENTIFIER),
39 | CR_SHIP_MODE_SK(IDENTIFIER),
40 | CR_WAREHOUSE_SK(IDENTIFIER),
41 | CR_REASON_SK(IDENTIFIER),
42 | CR_ORDER_NUMBER(IDENTIFIER),
43 | CR_RETURN_QUANTITY(INTEGER),
44 | CR_RETURN_AMOUNT(decimal(7, 2)),
45 | CR_RETURN_TAX(decimal(7, 2)),
46 | CR_RETURN_AMT_INC_TAX(decimal(7, 2)),
47 | CR_FEE(decimal(7, 2)),
48 | CR_RETURN_SHIP_COST(decimal(7, 2)),
49 | CR_REFUNDED_CASH(decimal(7, 2)),
50 | CR_REVERSED_CHARGE(decimal(7, 2)),
51 | CR_STORE_CREDIT(decimal(7, 2)),
52 | CR_NET_LOSS(decimal(7, 2));
53 |
54 | private final ColumnType type;
55 |
56 | CatalogReturnsColumn(ColumnType type)
57 | {
58 | this.type = type;
59 | }
60 |
61 | @Override
62 | public Table getTable()
63 | {
64 | return CATALOG_RETURNS;
65 | }
66 |
67 | @Override
68 | public String getName()
69 | {
70 | return name().toLowerCase();
71 | }
72 |
73 | @Override
74 | public ColumnType getType()
75 | {
76 | return type;
77 | }
78 |
79 | @Override
80 | public int getPosition()
81 | {
82 | return ordinal();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/StoreGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 |
19 | import static com.teradata.tpcds.Table.STORE;
20 |
21 | public enum StoreGeneratorColumn
22 | implements GeneratorColumn
23 | {
24 | W_STORE_SK(259, 1),
25 | W_STORE_ID(260, 1),
26 | W_STORE_REC_START_DATE_ID(261, 1),
27 | W_STORE_REC_END_DATE_ID(262, 2),
28 | W_STORE_CLOSED_DATE_ID(263, 2),
29 | W_STORE_NAME(264, 0),
30 | W_STORE_EMPLOYEES(265, 1),
31 | W_STORE_FLOOR_SPACE(266, 1),
32 | W_STORE_HOURS(267, 1),
33 | W_STORE_MANAGER(268, 2),
34 | W_STORE_MARKET_ID(269, 1),
35 | W_STORE_TAX_PERCENTAGE(270, 1),
36 | W_STORE_GEOGRAPHY_CLASS(271, 1),
37 | W_STORE_MARKET_DESC(272, 100),
38 | W_STORE_MARKET_MANAGER(273, 2),
39 | W_STORE_DIVISION_ID(274, 1),
40 | W_STORE_DIVISION_NAME(275, 1),
41 | W_STORE_COMPANY_ID(276, 1),
42 | W_STORE_COMPANY_NAME(277, 1),
43 | W_STORE_ADDRESS_STREET_NUM(278, 1),
44 | W_STORE_ADDRESS_STREET_NAME1(279, 1),
45 | W_STORE_ADDRESS_STREET_TYPE(280, 1),
46 | W_STORE_ADDRESS_SUITE_NUM(281, 1),
47 | W_STORE_ADDRESS_CITY(282, 1),
48 | W_STORE_ADDRESS_COUNTY(283, 1),
49 | W_STORE_ADDRESS_STATE(284, 1),
50 | W_STORE_ADDRESS_ZIP(285, 1),
51 | W_STORE_ADDRESS_COUNTRY(286, 1),
52 | W_STORE_ADDRESS_GMT_OFFSET(287, 1),
53 | W_STORE_NULLS(288, 2),
54 | W_STORE_TYPE(289, 1),
55 | W_STORE_SCD(290, 1),
56 | W_STORE_ADDRESS(291, 7);
57 |
58 | private final int globalColumnNumber;
59 | private final int seedsPerRow;
60 |
61 | StoreGeneratorColumn(int globalColumnNumber, int seedsPerRow)
62 | {
63 | this.globalColumnNumber = globalColumnNumber;
64 | this.seedsPerRow = seedsPerRow;
65 | }
66 |
67 | @Override
68 | public Table getTable()
69 | {
70 | return STORE;
71 | }
72 |
73 | @Override
74 | public int getGlobalColumnNumber()
75 | {
76 | return globalColumnNumber;
77 | }
78 |
79 | @Override
80 | public int getSeedsPerRow()
81 | {
82 | return seedsPerRow;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/WebSiteColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.WEB_SITE;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
21 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
22 | import static com.teradata.tpcds.column.ColumnTypes.character;
23 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
24 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
25 |
26 | public enum WebSiteColumn
27 | implements Column
28 | {
29 | WEB_SITE_SK(IDENTIFIER),
30 | WEB_SITE_ID(character(16)),
31 | WEB_REC_START_DATE(DATE),
32 | WEB_REC_END_DATE(DATE),
33 | WEB_NAME(varchar(50)),
34 | WEB_OPEN_DATE_SK(IDENTIFIER),
35 | WEB_CLOSE_DATE_SK(IDENTIFIER),
36 | WEB_CLASS(varchar(50)),
37 | WEB_MANAGER(varchar(40)),
38 | WEB_MKT_ID(INTEGER),
39 | WEB_MKT_CLASS(varchar(50)),
40 | WEB_MKT_DESC(varchar(100)),
41 | WEB_MARKET_MANAGER(varchar(40)),
42 | WEB_COMPANY_ID(INTEGER),
43 | WEB_COMPANY_NAME(character(50)),
44 | WEB_STREET_NUMBER(character(10)),
45 | WEB_STREET_NAME(varchar(60)),
46 | WEB_STREET_TYPE(character(15)),
47 | WEB_SUITE_NUMBER(character(10)),
48 | WEB_CITY(varchar(60)),
49 | WEB_COUNTY(varchar(30)),
50 | WEB_STATE(character(2)),
51 | WEB_ZIP(character(10)),
52 | WEB_COUNTRY(varchar(20)),
53 | WEB_GMT_OFFSET(decimal(5, 2)),
54 | WEB_TAX_PERCENTAGE(decimal(5, 2));
55 |
56 | private final ColumnType type;
57 |
58 | WebSiteColumn(ColumnType type)
59 | {
60 | this.type = type;
61 | }
62 |
63 | @Override
64 | public Table getTable()
65 | {
66 | return WEB_SITE;
67 | }
68 |
69 | @Override
70 | public String getName()
71 | {
72 | return name().toLowerCase();
73 | }
74 |
75 | @Override
76 | public ColumnType getType()
77 | {
78 | return type;
79 | }
80 |
81 | @Override
82 | public int getPosition()
83 | {
84 | return ordinal();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/StoreColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.STORE;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
21 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
22 | import static com.teradata.tpcds.column.ColumnTypes.character;
23 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
24 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
25 |
26 | public enum StoreColumn
27 | implements Column
28 | {
29 | S_STORE_SK(IDENTIFIER),
30 | S_STORE_ID(character(16)),
31 | S_REC_START_DATE(DATE),
32 | S_REC_END_DATE(DATE),
33 | S_CLOSED_DATE_SK(IDENTIFIER),
34 | S_STORE_NAME(varchar(50)),
35 | S_NUMBER_EMPLOYEES(INTEGER),
36 | S_FLOOR_SPACE(INTEGER),
37 | S_HOURS(character(20)),
38 | S_MANAGER(varchar(40)),
39 | S_MARKET_ID(INTEGER),
40 | S_GEOGRAPHY_CLASS(varchar(100)),
41 | S_MARKET_DESC(varchar(100)),
42 | S_MARKET_MANAGER(varchar(40)),
43 | S_DIVISION_ID(INTEGER),
44 | S_DIVISION_NAME(varchar(50)),
45 | S_COMPANY_ID(INTEGER),
46 | S_COMPANY_NAME(varchar(50)),
47 | S_STREET_NUMBER(varchar(10)),
48 | S_STREET_NAME(varchar(60)),
49 | S_STREET_TYPE(character(15)),
50 | S_SUITE_NUMBER(character(10)),
51 | S_CITY(varchar(60)),
52 | S_COUNTY(varchar(30)),
53 | S_STATE(character(2)),
54 | S_ZIP(character(10)),
55 | S_COUNTRY(varchar(20)),
56 | S_GMT_OFFSET(decimal(5, 2)),
57 | S_TAX_PRECENTAGE(decimal(5, 2));
58 |
59 | private final ColumnType type;
60 |
61 | StoreColumn(ColumnType type)
62 | {
63 | this.type = type;
64 | }
65 |
66 | @Override
67 | public Table getTable()
68 | {
69 | return STORE;
70 | }
71 |
72 | @Override
73 | public String getName()
74 | {
75 | return name().toLowerCase();
76 | }
77 |
78 | @Override
79 | public ColumnType getType()
80 | {
81 | return type;
82 | }
83 |
84 | @Override
85 | public int getPosition()
86 | {
87 | return ordinal();
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/colors.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- colors
3 | -- values weights
4 | -- -----------------------
5 | -- 1. color 1. uniform
6 | -- 2. skewed dist (used by dbgen)
7 | -- 3. low likelihood (used by qgen)
8 | -- 4. medium likelihood (used by qgen)
9 | -- 5. high likelihood (used by qgen)
10 | ------
11 | almond: 1, 1, 1, 0, 0
12 | antique: 1, 1, 1, 0, 0
13 | aquamarine: 1, 1, 1, 0, 0
14 | azure: 1, 1, 1, 0, 0
15 | beige: 1, 1, 1, 0, 0
16 | bisque: 1, 1, 1, 0, 0
17 | black: 1, 1, 1, 0, 0
18 | blanched: 1, 1, 1, 0, 0
19 | blue: 1, 1, 1, 0, 0
20 | blush: 1, 1, 1, 0, 0
21 | brown: 1, 1, 1, 0, 0
22 | burlywood: 1, 1, 1, 0, 0
23 | burnished: 1, 1, 1, 0, 0
24 | chartreuse: 1, 1, 1, 0, 0
25 | chiffon: 1, 1, 1, 0, 0
26 | chocolate: 1, 1, 1, 0, 0
27 | coral: 1, 1, 1, 0, 0
28 | cornflower: 1, 1, 1, 0, 0
29 | cornsilk: 1, 1, 1, 0, 0
30 | cream: 1, 1, 1, 0, 0
31 | cyan: 1, 1, 1, 0, 0
32 | dark: 1, 1, 1, 0, 0
33 | deep: 1, 1, 1, 0, 0
34 | dim: 1, 1, 1, 0, 0
35 | dodger: 1, 1, 1, 0, 0
36 | drab: 1, 1, 1, 0, 0
37 | firebrick: 1, 1, 1, 0, 0
38 | floral: 1, 1, 1, 0, 0
39 | forest: 1, 1, 1, 0, 0
40 | frosted: 1, 1, 1, 0, 0
41 | gainsboro: 1, 3, 0, 1, 0
42 | ghost: 1, 3, 0, 1, 0
43 | goldenrod: 1, 3, 0, 1, 0
44 | green: 1, 3, 0, 1, 0
45 | grey: 1, 3, 0, 1, 0
46 | honeydew: 1, 3, 0, 1, 0
47 | hot: 1, 3, 0, 1, 0
48 | indian: 1, 3, 0, 1, 0
49 | ivory: 1, 3, 0, 1, 0
50 | khaki: 1, 3, 0, 1, 0
51 | lace: 1, 3, 0, 1, 0
52 | lavender: 1, 3, 0, 1, 0
53 | lawn: 1, 3, 0, 1, 0
54 | lemon: 1, 3, 0, 1, 0
55 | light: 1, 3, 0, 1, 0
56 | lime: 1, 3, 0, 1, 0
57 | linen: 1, 3, 0, 1, 0
58 | magenta: 1, 3, 0, 1, 0
59 | maroon: 1, 3, 0, 1, 0
60 | medium: 1, 3, 0, 1, 0
61 | metallic: 1, 3, 0, 1, 0
62 | midnight: 1, 3, 0, 1, 0
63 | mint: 1, 3, 0, 1, 0
64 | misty: 1, 3, 0, 1, 0
65 | moccasin: 1, 3, 0, 1, 0
66 | navajo: 1, 3, 0, 1, 0
67 | navy: 1, 3, 0, 1, 0
68 | olive: 1, 3, 0, 1, 0
69 | orange: 1, 3, 0, 1, 0
70 | orchid: 1, 3, 0, 1, 0
71 | pale: 1, 9, 0, 0, 1
72 | papaya: 1, 9, 0, 0, 1
73 | peach: 1, 9, 0, 0, 1
74 | peru: 1, 9, 0, 0, 1
75 | pink: 1, 9, 0, 0, 1
76 | plum: 1, 9, 0, 0, 1
77 | powder: 1, 9, 0, 0, 1
78 | puff: 1, 9, 0, 0, 1
79 | purple: 1, 9, 0, 0, 1
80 | red: 1, 9, 0, 0, 1
81 | rose: 1, 9, 0, 0, 1
82 | rosy: 1, 9, 0, 0, 1
83 | royal: 1, 9, 0, 0, 1
84 | saddle: 1, 9, 0, 0, 1
85 | salmon: 1, 9, 0, 0, 1
86 | sandy: 1, 9, 0, 0, 1
87 | seashell: 1, 9, 0, 0, 1
88 | sienna: 1, 9, 0, 0, 1
89 | sky: 1, 9, 0, 0, 1
90 | slate: 1, 9, 0, 0, 1
91 | smoke: 1, 9, 0, 0, 1
92 | snow: 1, 9, 0, 0, 1
93 | spring: 1, 9, 0, 0, 1
94 | steel: 1, 9, 0, 0, 1
95 | tan: 1, 9, 0, 0, 1
96 | thistle: 1, 9, 0, 0, 1
97 | tomato: 1, 9, 0, 0, 1
98 | turquoise: 1, 9, 0, 0, 1
99 | violet: 1, 9, 0, 0, 1
100 | wheat: 1, 9, 0, 0, 1
101 | white: 1, 9, 0, 0, 1
102 | yellow: 1, 9, 0, 0, 1
103 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/distribution/AddressDistributions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.distribution;
16 |
17 | import com.teradata.tpcds.random.RandomNumberStream;
18 |
19 | import static com.teradata.tpcds.distribution.AddressDistributions.StreetNamesWeights.DEFAULT;
20 | import static com.teradata.tpcds.distribution.StringValuesDistribution.buildStringValuesDistribution;
21 |
22 | public final class AddressDistributions
23 | {
24 | private static final StringValuesDistribution STREET_NAMES_DISTRIBUTION = buildStringValuesDistribution("street_names.dst", 1, 2);
25 | private static final StringValuesDistribution STREET_TYPES_DISTRIBUTION = buildStringValuesDistribution("street_types.dst", 1, 1);
26 | private static final StringValuesDistribution CITIES_DISTRIBUTION = buildStringValuesDistribution("cities.dst", 1, 6);
27 | private static final StringValuesDistribution COUNTRIES_DISTRIBUTION = buildStringValuesDistribution("countries.dst", 1, 1);
28 |
29 | private AddressDistributions() {}
30 |
31 | public static String pickRandomStreetName(StreetNamesWeights streetNamesWeights, RandomNumberStream stream)
32 | {
33 | return STREET_NAMES_DISTRIBUTION.pickRandomValue(0, streetNamesWeights.ordinal(), stream);
34 | }
35 |
36 | public static String pickRandomStreetType(RandomNumberStream stream)
37 | {
38 | return STREET_TYPES_DISTRIBUTION.pickRandomValue(0, 0, stream);
39 | }
40 |
41 | public static String pickRandomCity(CitiesWeights citiesWeights, RandomNumberStream stream)
42 | {
43 | return CITIES_DISTRIBUTION.pickRandomValue(0, citiesWeights.ordinal(), stream);
44 | }
45 |
46 | public static String pickRandomCountry(RandomNumberStream stream)
47 | {
48 | return COUNTRIES_DISTRIBUTION.pickRandomValue(0, 0, stream);
49 | }
50 |
51 | public static String getCityAtIndex(int index)
52 | {
53 | return CITIES_DISTRIBUTION.getValueAtIndex(0, index);
54 | }
55 |
56 | public enum StreetNamesWeights
57 | {
58 | DEFAULT,
59 | HALF_EMPTY
60 | }
61 |
62 | public enum CitiesWeights
63 | {
64 | USGS_SKEWED,
65 | UNIFORM,
66 | LARGE,
67 | MEDIUM,
68 | SMALL,
69 | UNIFIED_STEP_FUNCTION
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/resources/com/teradata/tpcds/distribution/return_reasons.dst:
--------------------------------------------------------------------------------
1 | ------
2 | -- return_reasons
3 | ------
4 | -- values weights
5 | -- -----------------------
6 | -- 1. reason 1-6. not sure... none are ever used
7 | ------
8 | Package was damaged: 1, 0, 0, 0, 0, 0
9 | Stopped working: 1, 0, 0, 0, 0, 0
10 | Did not get it on time: 1, 0, 0, 0, 0, 0
11 | Not the product that was ordred: 1, 0, 0, 0, 0, 0
12 | Parts missing: 1, 0, 0, 0, 0, 0
13 | Does not work with a product that I have: 1, 0, 0, 0, 0, 0
14 | Gift exchange: 1, 0, 0, 0, 0, 0
15 | Did not like the color: 1, 0, 0, 0, 0, 0
16 | Did not like the model: 1, 0, 0, 0, 0, 0
17 | Did not like the make: 1, 0, 0, 0, 0, 0
18 | Did not like the warranty: 1, 0, 0, 0, 0, 0
19 | No service location in my area: 1, 0, 0, 0, 0, 0
20 | Found a better price in a store: 1, 0, 0, 0, 0, 0
21 | Found a better extended warranty in a store: 1, 0, 0, 0, 0, 0
22 | Not working any more: 1, 0, 0, 0, 0, 0
23 | Did not fit: 1, 0, 0, 0, 0, 0
24 | Wrong size: 1, 0, 0, 0, 0, 0
25 | Lost my job: 1, 0, 0, 0, 0, 0
26 | unauthoized purchase: 1, 0, 0, 0, 0, 0
27 | duplicate purchase: 1, 0, 0, 0, 0, 0
28 | its is a boy: 1, 0, 0, 0, 0, 0
29 | it is a girl: 1, 0, 0, 0, 0, 0
30 | reason 23: 1, 0, 0, 0, 0, 0
31 | reason 24: 1, 0, 0, 0, 0, 0
32 | reason 25: 1, 0, 0, 0, 0, 0
33 | reason 26: 1, 0, 0, 0, 0, 0
34 | reason 27: 1, 0, 0, 0, 0, 0
35 | reason 28: 1, 0, 0, 0, 0, 0
36 | reason 29: 1, 0, 0, 0, 0, 0
37 | reason 31: 1, 0, 0, 0, 0, 0
38 | reason 31: 1, 0, 0, 0, 0, 0
39 | reason 32: 1, 0, 0, 0, 0, 0
40 | reason 33: 1, 0, 0, 0, 0, 0
41 | reason 34: 1, 0, 0, 0, 0, 0
42 | reason 35: 1, 0, 0, 0, 0, 0
43 | reason 36: 1, 1, 0, 0, 0, 0
44 | reason 37: 1, 1, 0, 0, 0, 0
45 | reason 38: 1, 1, 0, 0, 0, 0
46 | reason 39: 1, 1, 0, 0, 0, 0
47 | reason 40: 1, 1, 0, 0, 0, 0
48 | reason 41: 1, 1, 0, 0, 0, 0
49 | reason 42: 1, 1, 0, 0, 0, 0
50 | reason 43: 1, 1, 0, 0, 0, 0
51 | reason 44: 1, 1, 0, 0, 0, 0
52 | reason 45: 1, 1, 0, 0, 0, 0
53 | reason 46: 1, 1, 1, 0, 0, 0
54 | reason 47: 1, 1, 1, 0, 0, 0
55 | reason 48: 1, 1, 1, 0, 0, 0
56 | reason 49: 1, 1, 1, 0, 0, 0
57 | reason 50: 1, 1, 1, 0, 0, 0
58 | reason 51: 1, 1, 1, 0, 0, 0
59 | reason 52: 1, 1, 1, 0, 0, 0
60 | reason 53: 1, 1, 1, 0, 0, 0
61 | reason 54: 1, 1, 1, 0, 0, 0
62 | reason 55: 1, 1, 1, 0, 0, 0
63 | reason 56: 1, 1, 1, 1, 0, 0
64 | reason 57: 1, 1, 1, 1, 0, 0
65 | reason 58: 1, 1, 1, 1, 0, 0
66 | reason 59: 1, 1, 1, 1, 0, 0
67 | reason 60: 1, 1, 1, 1, 0, 0
68 | reason 61: 1, 1, 1, 1, 0, 0
69 | reason 62: 1, 1, 1, 1, 0, 0
70 | reason 63: 1, 1, 1, 1, 0, 0
71 | reason 64: 1, 1, 1, 1, 0, 0
72 | reason 65: 1, 1, 1, 1, 0, 0
73 | reason 66: 1, 1, 1, 1, 1, 0
74 | reason 67: 1, 1, 1, 1, 1, 0
75 | reason 68: 1, 1, 1, 1, 1, 0
76 | reason 69: 1, 1, 1, 1, 1, 0
77 | reason 70: 1, 1, 1, 1, 1, 0
78 | reason 71: 1, 1, 1, 1, 1, 1
79 | reason 72: 1, 1, 1, 1, 1, 1
80 | reason 73: 1, 1, 1, 1, 1, 1
81 | reason 74: 1, 1, 1, 1, 1, 1
82 | reason 75: 1, 1, 1, 1, 1, 1
83 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/generator/CatalogReturnsGeneratorColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.generator;
16 |
17 | import com.teradata.tpcds.Table;
18 | import com.teradata.tpcds.random.RandomNumberStream;
19 | import com.teradata.tpcds.random.RandomNumberStreamImpl;
20 |
21 | import static com.teradata.tpcds.Table.CATALOG_RETURNS;
22 |
23 | public enum CatalogReturnsGeneratorColumn
24 | implements GeneratorColumn
25 | {
26 | CR_RETURNED_DATE_SK(46, 28),
27 | CR_RETURNED_TIME_SK(47, 28),
28 | CR_ITEM_SK(48, 14),
29 | CR_REFUNDED_CUSTOMER_SK(49, 14),
30 | CR_REFUNDED_CDEMO_SK(50, 14),
31 | CR_REFUNDED_HDEMO_SK(51, 14),
32 | CR_REFUNDED_ADDR_SK(52, 14),
33 | CR_RETURNING_CUSTOMER_SK(53, 28),
34 | CR_RETURNING_CDEMO_SK(54, 14),
35 | CR_RETURNING_HDEMO_SK(55, 14),
36 | CR_RETURNING_ADDR_SK(56, 14),
37 | CR_CALL_CENTER_SK(57, 0),
38 | CR_CATALOG_PAGE_SK(58, 14),
39 | CR_SHIP_MODE_SK(59, 14),
40 | CR_WAREHOUSE_SK(60, 14),
41 | CR_REASON_SK(61, 14),
42 | CR_ORDER_NUMBER(62, 0),
43 | CR_PRICING_QUANTITY(63, 0),
44 | CR_PRICING_NET_PAID(64, 0),
45 | CR_PRICING_EXT_TAX(65, 0),
46 | CR_PRICING_NET_PAID_INC_TAX(66, 0),
47 | CR_PRICING_FEE(67, 0),
48 | CR_PRICING_EXT_SHIP_COST(68, 0),
49 | CR_PRICING_REFUNDED_CASH(69, 0),
50 | CR_PRICING_REVERSED_CHARGE(70, 0),
51 | CR_PRICING_STORE_CREDIT(71, 0),
52 | CR_PRICING_NET_LOSS(72, 0),
53 | CR_NULLS(73, 28),
54 | CR_PRICING(74, 70);
55 |
56 | private final RandomNumberStream randomNumberStream;
57 | private final int globalColumnNumber;
58 | private final int seedsPerRow;
59 |
60 | CatalogReturnsGeneratorColumn(int globalColumnNumber, int seedsPerRow)
61 | {
62 | this.globalColumnNumber = globalColumnNumber;
63 | this.randomNumberStream = new RandomNumberStreamImpl(globalColumnNumber, seedsPerRow);
64 | this.seedsPerRow = seedsPerRow;
65 | }
66 |
67 | @Override
68 | public Table getTable()
69 | {
70 | return CATALOG_RETURNS;
71 | }
72 |
73 | @Override
74 | public int getGlobalColumnNumber()
75 | {
76 | return globalColumnNumber;
77 | }
78 |
79 | @Override
80 | public int getSeedsPerRow()
81 | {
82 | return seedsPerRow;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/ShipModeRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.row.ShipModeRow;
19 |
20 | import static com.teradata.tpcds.BusinessKeyGenerator.makeBusinessKey;
21 | import static com.teradata.tpcds.Nulls.createNullBitMap;
22 | import static com.teradata.tpcds.Table.SHIP_MODE;
23 | import static com.teradata.tpcds.distribution.ShipModeDistributions.SHIP_MODE_TYPE_DISTRIBUTION;
24 | import static com.teradata.tpcds.distribution.ShipModeDistributions.getShipModeCarrierAtIndex;
25 | import static com.teradata.tpcds.distribution.ShipModeDistributions.getShipModeCodeForIndexModSize;
26 | import static com.teradata.tpcds.distribution.ShipModeDistributions.getShipModeTypeForIndexModSize;
27 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_CONTRACT;
28 | import static com.teradata.tpcds.generator.ShipModeGeneratorColumn.SM_NULLS;
29 | import static com.teradata.tpcds.random.RandomValueGenerator.ALPHA_NUMERIC;
30 | import static com.teradata.tpcds.random.RandomValueGenerator.generateRandomCharset;
31 |
32 | public class ShipModeRowGenerator
33 | extends AbstractRowGenerator
34 | {
35 | public ShipModeRowGenerator()
36 | {
37 | super(SHIP_MODE);
38 | }
39 |
40 | @Override
41 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
42 | {
43 | long nullBitMap = createNullBitMap(SHIP_MODE, getRandomNumberStream(SM_NULLS));
44 | long smShipModeSk = rowNumber;
45 | String smShipModeId = makeBusinessKey(rowNumber);
46 |
47 | long index = rowNumber;
48 |
49 | String smType = getShipModeTypeForIndexModSize(rowNumber);
50 | index /= SHIP_MODE_TYPE_DISTRIBUTION.getSize();
51 |
52 | String smCode = getShipModeCodeForIndexModSize(index);
53 |
54 | String smCarrier = getShipModeCarrierAtIndex((int) (rowNumber) - 1);
55 |
56 | String smContract = generateRandomCharset(ALPHA_NUMERIC, 1, 20, getRandomNumberStream(SM_CONTRACT));
57 |
58 | return new RowGeneratorResult(new ShipModeRow(nullBitMap, smShipModeSk, smShipModeId, smType, smCode, smCarrier, smContract));
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/row/generator/HouseholdDemographicsRowGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.teradata.tpcds.row.generator;
16 |
17 | import com.teradata.tpcds.Session;
18 | import com.teradata.tpcds.row.HouseholdDemographicsRow;
19 |
20 | import static com.teradata.tpcds.Nulls.createNullBitMap;
21 | import static com.teradata.tpcds.Table.HOUSEHOLD_DEMOGRAPHICS;
22 | import static com.teradata.tpcds.distribution.DemographicsDistributions.BUY_POTENTIAL_DISTRIBUTION;
23 | import static com.teradata.tpcds.distribution.DemographicsDistributions.DEP_COUNT_DISTRIBUTION;
24 | import static com.teradata.tpcds.distribution.DemographicsDistributions.INCOME_BAND_DISTRIBUTION;
25 | import static com.teradata.tpcds.distribution.DemographicsDistributions.getBuyPotentialForIndexModSize;
26 | import static com.teradata.tpcds.distribution.DemographicsDistributions.getDepCountForIndexModSize;
27 | import static com.teradata.tpcds.distribution.DemographicsDistributions.getVehicleCountForIndexModSize;
28 | import static com.teradata.tpcds.generator.HouseholdDemographicsGeneratorColumn.HD_NULLS;
29 |
30 | public class HouseholdDemographicsRowGenerator
31 | extends AbstractRowGenerator
32 | {
33 | public HouseholdDemographicsRowGenerator()
34 | {
35 | super(HOUSEHOLD_DEMOGRAPHICS);
36 | }
37 |
38 | @Override
39 | public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator)
40 | {
41 | long nullBitMap = createNullBitMap(HOUSEHOLD_DEMOGRAPHICS, getRandomNumberStream(HD_NULLS));
42 | long hdDemoSk = rowNumber;
43 | long index = hdDemoSk;
44 | long hdIncomeBandId = (index % INCOME_BAND_DISTRIBUTION.getSize()) + 1;
45 |
46 | index /= INCOME_BAND_DISTRIBUTION.getSize();
47 | String hdBuyPotential = getBuyPotentialForIndexModSize(index);
48 |
49 | index /= BUY_POTENTIAL_DISTRIBUTION.getSize();
50 | int hdDepCount = getDepCountForIndexModSize(index);
51 |
52 | index /= DEP_COUNT_DISTRIBUTION.getSize();
53 | int hdVehicleCount = getVehicleCountForIndexModSize(index);
54 |
55 | return new RowGeneratorResult(new HouseholdDemographicsRow(nullBitMap, hdDemoSk, hdIncomeBandId, hdBuyPotential, hdDepCount, hdVehicleCount));
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/teradata/tpcds/column/CallCenterColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.teradata.tpcds.column;
15 |
16 | import com.teradata.tpcds.Table;
17 |
18 | import static com.teradata.tpcds.Table.CALL_CENTER;
19 | import static com.teradata.tpcds.column.ColumnTypes.DATE;
20 | import static com.teradata.tpcds.column.ColumnTypes.IDENTIFIER;
21 | import static com.teradata.tpcds.column.ColumnTypes.INTEGER;
22 | import static com.teradata.tpcds.column.ColumnTypes.character;
23 | import static com.teradata.tpcds.column.ColumnTypes.decimal;
24 | import static com.teradata.tpcds.column.ColumnTypes.varchar;
25 |
26 | public enum CallCenterColumn
27 | implements Column
28 | {
29 | CC_CALL_CENTER_SK(IDENTIFIER),
30 | CC_CALL_CENTER_ID(character(16)),
31 | CC_REC_START_DATE(DATE),
32 | CC_REC_END_DATE(DATE),
33 | CC_CLOSED_DATE_SK(INTEGER),
34 | CC_OPEN_DATE_SK(INTEGER),
35 | CC_NAME(varchar(50)),
36 | CC_CLASS(varchar(50)),
37 | CC_EMPLOYEES(INTEGER),
38 | CC_SQ_FT(INTEGER),
39 | CC_HOURS(character(20)),
40 | CC_MANAGER(varchar(40)),
41 | CC_MKT_ID(INTEGER),
42 | CC_MKT_CLASS(character(50)),
43 | CC_MKT_DESC(varchar(100)),
44 | CC_MARKET_MANAGER(varchar(40)),
45 | CC_DIVISION(INTEGER),
46 | CC_DIVISION_NAME(varchar(50)),
47 | CC_COMPANY(INTEGER),
48 | CC_COMPANY_NAME(character(50)),
49 | CC_STREET_NUMBER(character(10)),
50 | CC_STREET_NAME(varchar(60)),
51 | CC_STREET_TYPE(character(15)),
52 | CC_SUITE_NUMBER(character(10)),
53 | CC_CITY(varchar(60)),
54 | CC_COUNTY(varchar(30)),
55 | CC_STATE(character(2)),
56 | CC_ZIP(character(10)),
57 | CC_COUNTRY(varchar(20)),
58 | CC_GMT_OFFSET(decimal(5, 2)),
59 | CC_TAX_PERCENTAGE(decimal(5, 2));
60 |
61 | private final ColumnType type;
62 |
63 | CallCenterColumn(ColumnType type)
64 | {
65 | this.type = type;
66 | }
67 |
68 | @Override
69 | public Table getTable()
70 | {
71 | return CALL_CENTER;
72 | }
73 |
74 | @Override
75 | public String getName()
76 | {
77 | return name().toLowerCase();
78 | }
79 |
80 | @Override
81 | public ColumnType getType()
82 | {
83 | return type;
84 | }
85 |
86 | @Override
87 | public int getPosition()
88 | {
89 | return ordinal();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------