diff --git a/velox/connectors/tpch/TpchConnector.cpp b/velox/connectors/tpch/TpchConnector.cpp
index 007cbaadece8..6da7a2118126 100644
--- a/velox/connectors/tpch/TpchConnector.cpp
+++ b/velox/connectors/tpch/TpchConnector.cpp
@@ -129,8 +129,9 @@ void TpchDataSource::addSplit(std::shared_ptr<ConnectorSplit> split) {
   currentSplit_ = std::dynamic_pointer_cast<TpchConnectorSplit>(split);
   VELOX_CHECK(currentSplit_, "Wrong type of split for TpchDataSource.");
 
-  size_t partSize =
-      std::ceil((double)tpchTableRowCount_ / (double)currentSplit_->totalParts);
+  size_t partSize = std::ceil(
+      static_cast<double>(tpchTableRowCount_) /
+      static_cast<double>(currentSplit_->totalParts));
 
   splitOffset_ = partSize * currentSplit_->partNumber;
   splitEnd_ = splitOffset_ + partSize;
diff --git a/velox/tpch/gen/TpchGen.cpp b/velox/tpch/gen/TpchGen.cpp
index 464a6c5dd34e..f2cb8c6c799e 100644
--- a/velox/tpch/gen/TpchGen.cpp
+++ b/velox/tpch/gen/TpchGen.cpp
@@ -78,7 +78,7 @@ std::vector<VectorPtr> allocateVectors(
 }
 
 double decimalToDouble(int64_t value) {
-  return (double)value * 0.01;
+  return static_cast<double>(value) * 0.01;
 }
 
 int32_t toDate(std::string_view stringDate) {
diff --git a/velox/tpch/gen/dbgen/bm_utils.cpp b/velox/tpch/gen/dbgen/bm_utils.cpp
index acfe2fb99432..d1e1b501f5bd 100644
--- a/velox/tpch/gen/dbgen/bm_utils.cpp
+++ b/velox/tpch/gen/dbgen/bm_utils.cpp
@@ -153,8 +153,8 @@ void e_str(distribution* d, int min, int max, seed_t* seed, char* dest) {
 
   tpch_a_rnd(min, max, seed, dest);
   pick_str(d, seed, strtmp);
-  len = (int)strlen(strtmp);
-  RANDOM(loc, 0, ((int)strlen(dest) - 1 - len), seed);
+  len = static_cast<int>(strlen(strtmp));
+  RANDOM(loc, 0, (static_cast<int>(strlen(dest)) - 1 - len), seed);
   memcpy(dest + loc, strtmp, sizeof(char) * len);
 
   return;
@@ -277,12 +277,14 @@ void read_dist(const char* path, const char* name, distribution* target) {
 
     if (!dsscasecmp(token, "count")) {
       target->count = weight;
-      target->list = (set_member*)malloc((size_t)(weight * sizeof(set_member)));
+      target->list =
+          (set_member*)malloc(static_cast<size_t>(weight * sizeof(set_member)));
       MALLOC_CHECK(target->list);
       target->max = 0;
       continue;
     }
-    target->list[count].text = (char*)malloc((size_t)((int)strlen(token) + 1));
+    target->list[count].text = reinterpret_cast<char*>(
+        malloc(static_cast<size_t>((static_cast<int>(strlen(token)) + 1))));
     MALLOC_CHECK(target->list[count].text);
     strcpy(target->list[count].text, token);
     target->max += weight;
@@ -295,7 +297,7 @@ void read_dist(const char* path, const char* name, distribution* target) {
     fprintf(stderr, "Read error on dist '%s'\n", name);
     exit(1);
   }
-  target->permute = (long*)NULL;
+  target->permute = reinterpret_cast<long*>(NULL);
   return;
 }
 
@@ -315,7 +317,7 @@ void agg_str(distribution* set, long count, seed_t* seed, char* dest) {
     strcat(dest, DIST_MEMBER(set, DIST_PERMUTE(d, i)));
     strcat(dest, " ");
   }
-  *(dest + (int)strlen(dest) - 1) = '\0';
+  *(dest + static_cast<int>(strlen(dest)) - 1) = '\0';
 
   return;
 }
@@ -398,7 +400,7 @@ char** mk_ascdate(void) {
   dss_time_t t;
   DSS_HUGE i;
 
-  m = (char**)malloc((size_t)(TOTDATE * sizeof(char*)));
+  m = reinterpret_cast<char**>(malloc((size_t)(TOTDATE * sizeof(char*))));
   MALLOC_CHECK(m);
   for (i = 0; i < TOTDATE; i++) {
     mk_time(i + 1, &t);
diff --git a/velox/tpch/gen/dbgen/build.cpp b/velox/tpch/gen/dbgen/build.cpp
index fb18431b09c4..a2cea0fd9cad 100644
--- a/velox/tpch/gen/dbgen/build.cpp
+++ b/velox/tpch/gen/dbgen/build.cpp
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /*
  * Copyright owned by the Transaction Processing Performance Council.
  *
@@ -28,17 +43,28 @@ namespace facebook::velox::tpch::dbgen {
 #define JDAY_BASE 8035 /* start from 1/1/70 a la unix */
 #define JMNTH_BASE (-70 * 12) /* start from 1/1/70 a la unix */
 #define JDAY(date) ((date) - STARTDATE + JDAY_BASE + 1)
-#define PART_SUPP_BRIDGE(tgt, p, s)                                           \
-  {                                                                           \
-    DSS_HUGE tot_scnt = ctx->tdefs[SUPP].base * ctx->scale_factor;            \
-    tgt = (p + s * (tot_scnt / SUPP_PER_PART + (long)((p - 1) / tot_scnt))) % \
-            tot_scnt +                                                        \
-        1;                                                                    \
+#define PART_SUPP_BRIDGE(tgt, p, s)                                \
+  {                                                                \
+    DSS_HUGE tot_scnt = ctx->tdefs[SUPP].base * ctx->scale_factor; \
+    tgt = (p +                                                     \
+           s *                                                     \
+               (tot_scnt / SUPP_PER_PART +                         \
+                static_cast<long>((p - 1) / tot_scnt))) %          \
+            tot_scnt +                                             \
+        1;                                                         \
   }
-#define V_STR(avg, seed, tgt) \
-  tpch_a_rnd((int)(avg * V_STR_LOW), (int)(avg * V_STR_HGH), seed, tgt)
-#define TEXT(avg, seed, tgt) \
-  dbg_text(tgt, (int)(avg * V_STR_LOW), (int)(avg * V_STR_HGH), seed)
+#define V_STR(avg, seed, tgt)            \
+  tpch_a_rnd(                            \
+      static_cast<int>(avg * V_STR_LOW), \
+      static_cast<int>(avg * V_STR_HGH), \
+      seed,                              \
+      tgt)
+#define TEXT(avg, seed, tgt)             \
+  dbg_text(                              \
+      tgt,                               \
+      static_cast<int>(avg * V_STR_LOW), \
+      static_cast<int>(avg * V_STR_HGH), \
+      seed)
 static void gen_phone PROTO((DSS_HUGE ind, char* target, seed_t* seed));
 
 DSS_HUGE
@@ -59,10 +85,10 @@ static void gen_phone(DSS_HUGE ind, char* target, seed_t* seed) {
   RANDOM(exchg, 100, 999, seed);
   RANDOM(number, 1000, 9999, seed);
 
-  sprintf(target, "%02d", (int)(10 + (ind % NATIONS_MAX)));
-  sprintf(target + 3, "%03d", (int)acode);
-  sprintf(target + 7, "%03d", (int)exchg);
-  sprintf(target + 11, "%04d", (int)number);
+  sprintf(target, "%02d", static_cast<int>(10 + (ind % NATIONS_MAX)));
+  sprintf(target + 3, "%03d", static_cast<int>(acode));
+  sprintf(target + 7, "%03d", static_cast<int>(exchg));
+  sprintf(target + 11, "%04d", static_cast<int>(number));
   target[2] = target[6] = target[10] = '-';
 
   return;
@@ -80,14 +106,14 @@ long mk_cust(DSS_HUGE n_cust, customer_t* c, DBGenContext* ctx) {
   c->custkey = n_cust;
   sprintf(c->name, szFormat, C_NAME_TAG, n_cust);
   V_STR(C_ADDR_LEN, &ctx->Seed[C_ADDR_SD], c->address);
-  c->alen = (int)strlen(c->address);
+  c->alen = static_cast<int>(strlen(c->address));
   RANDOM(i, 0, (nations.count - 1), &ctx->Seed[C_NTRG_SD]);
   c->nation_code = i;
   gen_phone(i, c->phone, &ctx->Seed[C_PHNE_SD]);
   RANDOM(c->acctbal, C_ABAL_MIN, C_ABAL_MAX, &ctx->Seed[C_ABAL_SD]);
   pick_str(&c_mseg_set, &ctx->Seed[C_MSEG_SD], c->mktsegment);
   TEXT(C_CMNT_LEN, &ctx->Seed[C_CMNT_SD], c->comment);
-  c->clen = (int)strlen(c->comment);
+  c->clen = static_cast<int>(strlen(c->comment));
 
   return (0);
 }
@@ -99,7 +125,7 @@ void mk_sparse(DSS_HUGE i, DSS_HUGE* ok, long seq) {
   long low_bits;
 
   *ok = i;
-  low_bits = (long)(i & ((1 << SPARSE_KEEP) - 1));
+  low_bits = static_cast<long>(i & ((1 << SPARSE_KEEP) - 1));
   *ok = *ok >> SPARSE_KEEP;
   *ok = *ok << SPARSE_BITS;
   *ok += seq;
@@ -155,7 +181,7 @@ long mk_order(DSS_HUGE index, order_t* o, DBGenContext* ctx, long upd_num) {
       &ctx->Seed[O_CLRK_SD]);
   sprintf(o->clerk, szFormat, O_CLRK_TAG, clk_num);
   TEXT(O_CMNT_LEN, &ctx->Seed[O_CMNT_SD], o->comment);
-  o->clen = (int)strlen(o->comment);
+  o->clen = static_cast<int>(strlen(o->comment));
 #ifdef DEBUG
   if (o->clen > O_CMNT_MAX)
     fprintf(stderr, "comment error: O%d\n", index);
@@ -177,7 +203,7 @@ long mk_order(DSS_HUGE index, order_t* o, DBGenContext* ctx, long upd_num) {
     pick_str(&l_instruct_set, &ctx->Seed[L_SHIP_SD], o->l[lcnt].shipinstruct);
     pick_str(&l_smode_set, &ctx->Seed[L_SMODE_SD], o->l[lcnt].shipmode);
     TEXT(L_CMNT_LEN, &ctx->Seed[L_CMNT_SD], o->l[lcnt].comment);
-    o->l[lcnt].clen = (int)strlen(o->l[lcnt].comment);
+    o->l[lcnt].clen = static_cast<int>(strlen(o->l[lcnt].comment));
     if (ctx->scale_factor >= 30000)
       RANDOM64(
           o->l[lcnt].partkey, L_PKEY_MIN, L_PKEY_MAX, &ctx->Seed[L_PKEY_SD]);
@@ -188,9 +214,10 @@ long mk_order(DSS_HUGE index, order_t* o, DBGenContext* ctx, long upd_num) {
     PART_SUPP_BRIDGE(o->l[lcnt].suppkey, o->l[lcnt].partkey, supp_num);
     o->l[lcnt].eprice = rprice * o->l[lcnt].quantity;
 
-    o->totalprice += ((o->l[lcnt].eprice * ((long)100 - o->l[lcnt].discount)) /
-                      (long)PENNIES) *
-        ((long)100 + o->l[lcnt].tax) / (long)PENNIES;
+    o->totalprice +=
+        (o->l[lcnt].eprice * (static_cast<long>(100) - o->l[lcnt].discount)) /
+        static_cast<long>(PENNIES) * (static_cast<long>(100) + o->l[lcnt].tax) /
+        static_cast<long>(PENNIES);
 
     RANDOM(s_date, L_SDTE_MIN, L_SDTE_MAX, &ctx->Seed[L_SDTE_SD]);
     s_date += tmp_date;
@@ -238,18 +265,19 @@ long mk_part(DSS_HUGE index, part_t* p, DBGenContext* ctx) {
     bInit = 1;
   }
   p->partkey = index;
-  agg_str(&colors, (long)P_NAME_SCL, &ctx->Seed[P_NAME_SD], p->name);
+  agg_str(
+      &colors, static_cast<long>(P_NAME_SCL), &ctx->Seed[P_NAME_SD], p->name);
   RANDOM(temp, P_MFG_MIN, P_MFG_MAX, &ctx->Seed[P_MFG_SD]);
   sprintf(p->mfgr, szFormat, P_MFG_TAG, temp);
   RANDOM(brnd, P_BRND_MIN, P_BRND_MAX, &ctx->Seed[P_BRND_SD]);
   sprintf(p->brand, szBrandFormat, P_BRND_TAG, (temp * 10 + brnd));
   p->tlen = pick_str(&p_types_set, &ctx->Seed[P_TYPE_SD], p->type);
-  p->tlen = (int)strlen(p_types_set.list[p->tlen].text);
+  p->tlen = static_cast<int>(strlen(p_types_set.list[p->tlen].text));
   RANDOM(p->size, P_SIZE_MIN, P_SIZE_MAX, &ctx->Seed[P_SIZE_SD]);
   pick_str(&p_cntr_set, &ctx->Seed[P_CNTR_SD], p->container);
   p->retailprice = rpb_routine(index);
   TEXT(P_CMNT_LEN, &ctx->Seed[P_CMNT_SD], p->comment);
-  p->clen = (int)strlen(p->comment);
+  p->clen = static_cast<int>(strlen(p->comment));
 
   for (snum = 0; snum < SUPP_PER_PART; snum++) {
     p->s[snum].partkey = p->partkey;
@@ -257,7 +285,7 @@ long mk_part(DSS_HUGE index, part_t* p, DBGenContext* ctx) {
     RANDOM(p->s[snum].qty, PS_QTY_MIN, PS_QTY_MAX, &ctx->Seed[PS_QTY_SD]);
     RANDOM(p->s[snum].scost, PS_SCST_MIN, PS_SCST_MAX, &ctx->Seed[PS_SCST_SD]);
     TEXT(PS_CMNT_LEN, &ctx->Seed[PS_CMNT_SD], p->s[snum].comment);
-    p->s[snum].clen = (int)strlen(p->s[snum].comment);
+    p->s[snum].clen = static_cast<int>(strlen(p->s[snum].comment));
   }
   return (0);
 }
@@ -274,14 +302,14 @@ long mk_supp(DSS_HUGE index, supplier_t* s, DBGenContext* ctx) {
   s->suppkey = index;
   sprintf(s->name, szFormat, S_NAME_TAG, index);
   V_STR(S_ADDR_LEN, &ctx->Seed[S_ADDR_SD], s->address);
-  s->alen = (int)strlen(s->address);
+  s->alen = static_cast<int>(strlen(s->address));
   RANDOM(i, 0, nations.count - 1, &ctx->Seed[S_NTRG_SD]);
   s->nation_code = i;
   gen_phone(i, s->phone, &ctx->Seed[S_PHNE_SD]);
   RANDOM(s->acctbal, S_ABAL_MIN, S_ABAL_MAX, &ctx->Seed[S_ABAL_SD]);
 
   TEXT(S_CMNT_LEN, &ctx->Seed[S_CMNT_SD], s->comment);
-  s->clen = (int)strlen(s->comment);
+  s->clen = static_cast<int>(strlen(s->comment));
   /*
    * these calls should really move inside the if stmt below, but this
    * will simplify seedless parallel load
@@ -353,7 +381,7 @@ int mk_nation(DSS_HUGE index, code_t* c, DBGenContext* ctx) {
   c->text = nations.list[index - 1].text;
   c->join = nations.list[index - 1].weight;
   TEXT(N_CMNT_LEN, &ctx->Seed[N_CMNT_SD], c->comment);
-  c->clen = (int)strlen(c->comment);
+  c->clen = static_cast<int>(strlen(c->comment));
   return (0);
 }
 
@@ -362,7 +390,7 @@ int mk_region(DSS_HUGE index, code_t* c, DBGenContext* ctx) {
   c->text = regions.list[index - 1].text;
   c->join = 0; /* for completeness */
   TEXT(R_CMNT_LEN, &ctx->Seed[R_CMNT_SD], c->comment);
-  c->clen = (int)strlen(c->comment);
+  c->clen = static_cast<int>(strlen(c->comment));
   return (0);
 }
 
diff --git a/velox/tpch/gen/dbgen/include/dbgen/dss.h b/velox/tpch/gen/dbgen/include/dbgen/dss.h
index 323da69ea056..f5bcf979de9e 100644
--- a/velox/tpch/gen/dbgen/include/dbgen/dss.h
+++ b/velox/tpch/gen/dbgen/include/dbgen/dss.h
@@ -135,7 +135,7 @@ typedef struct {
  * some handy access functions
  */
 #define DIST_SIZE(d) d->count
-#define DIST_MEMBER(d, i) ((set_member*)((d)->list + i))->text
+#define DIST_MEMBER(d, i) (reinterpret_cast<set_member*>((d)->list + i))->text
 #define DIST_PERMUTE(d, i) (d->permute[i])
 
 typedef struct {
diff --git a/velox/tpch/gen/dbgen/include/tpch_constants.hpp b/velox/tpch/gen/dbgen/include/tpch_constants.hpp
index 9a1604b46f1a..cf0c2ce06a55 100644
--- a/velox/tpch/gen/dbgen/include/tpch_constants.hpp
+++ b/velox/tpch/gen/dbgen/include/tpch_constants.hpp
@@ -1,9 +1,26 @@
+/*
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /* THIS FILE WAS AUTOMATICALLY GENERATED BY generate_csv_header.py */
 
 #pragma once
 
 namespace facebook::velox::tpch::dbgen {
 
+#define CONST_CHAR_CAST reinterpret_cast<const char*>
+
 const int TPCH_QUERIES_COUNT = 22;
 const uint8_t TPCH_QUERIES_q01[] = {
     83,  69,  76,  69,  67,  84,  10,  32,  32,  32,  32,  108, 95,  114, 101,
@@ -982,17 +999,17 @@ const uint8_t TPCH_QUERIES_q22[] = {
     100, 101, 10,  79,  82,  68,  69,  82,  32,  66,  89,  10,  32,  32,  32,
     32,  99,  110, 116, 114, 121, 99,  111, 100, 101, 59,  10,  0};
 const char* TPCH_QUERIES[] = {
-    (const char*)TPCH_QUERIES_q01, (const char*)TPCH_QUERIES_q02,
-    (const char*)TPCH_QUERIES_q03, (const char*)TPCH_QUERIES_q04,
-    (const char*)TPCH_QUERIES_q05, (const char*)TPCH_QUERIES_q06,
-    (const char*)TPCH_QUERIES_q07, (const char*)TPCH_QUERIES_q08,
-    (const char*)TPCH_QUERIES_q09, (const char*)TPCH_QUERIES_q10,
-    (const char*)TPCH_QUERIES_q11, (const char*)TPCH_QUERIES_q12,
-    (const char*)TPCH_QUERIES_q13, (const char*)TPCH_QUERIES_q14,
-    (const char*)TPCH_QUERIES_q15, (const char*)TPCH_QUERIES_q16,
-    (const char*)TPCH_QUERIES_q17, (const char*)TPCH_QUERIES_q18,
-    (const char*)TPCH_QUERIES_q19, (const char*)TPCH_QUERIES_q20,
-    (const char*)TPCH_QUERIES_q21, (const char*)TPCH_QUERIES_q22};
+    CONST_CHAR_CAST(TPCH_QUERIES_q01), CONST_CHAR_CAST(TPCH_QUERIES_q02),
+    CONST_CHAR_CAST(TPCH_QUERIES_q03), CONST_CHAR_CAST(TPCH_QUERIES_q04),
+    CONST_CHAR_CAST(TPCH_QUERIES_q05), CONST_CHAR_CAST(TPCH_QUERIES_q06),
+    CONST_CHAR_CAST(TPCH_QUERIES_q07), CONST_CHAR_CAST(TPCH_QUERIES_q08),
+    CONST_CHAR_CAST(TPCH_QUERIES_q09), CONST_CHAR_CAST(TPCH_QUERIES_q10),
+    CONST_CHAR_CAST(TPCH_QUERIES_q11), CONST_CHAR_CAST(TPCH_QUERIES_q12),
+    CONST_CHAR_CAST(TPCH_QUERIES_q13), CONST_CHAR_CAST(TPCH_QUERIES_q14),
+    CONST_CHAR_CAST(TPCH_QUERIES_q15), CONST_CHAR_CAST(TPCH_QUERIES_q16),
+    CONST_CHAR_CAST(TPCH_QUERIES_q17), CONST_CHAR_CAST(TPCH_QUERIES_q18),
+    CONST_CHAR_CAST(TPCH_QUERIES_q19), CONST_CHAR_CAST(TPCH_QUERIES_q20),
+    CONST_CHAR_CAST(TPCH_QUERIES_q21), CONST_CHAR_CAST(TPCH_QUERIES_q22)};
 const uint8_t TPCH_ANSWERS_SF0_01_q01[] = {
     108, 95,  114, 101, 116, 117, 114, 110, 102, 108, 97,  103, 124, 108, 95,
     108, 105, 110, 101, 115, 116, 97,  116, 117, 115, 124, 115, 117, 109, 95,
@@ -2808,17 +2825,18 @@ const uint8_t TPCH_ANSWERS_SF0_01_q22[] = {
     124, 49,  55,  124, 49,  50,  50,  49,  56,  57,  46,  51,  51,  10, 51,
     49,  124, 56,  124, 54,  54,  51,  49,  51,  46,  49,  54,  10,  0};
 const char* TPCH_ANSWERS_SF0_01[] = {
-    (const char*)TPCH_ANSWERS_SF0_01_q01, (const char*)TPCH_ANSWERS_SF0_01_q02,
-    (const char*)TPCH_ANSWERS_SF0_01_q03, (const char*)TPCH_ANSWERS_SF0_01_q04,
-    (const char*)TPCH_ANSWERS_SF0_01_q05, (const char*)TPCH_ANSWERS_SF0_01_q06,
-    (const char*)TPCH_ANSWERS_SF0_01_q07, (const char*)TPCH_ANSWERS_SF0_01_q08,
-    (const char*)TPCH_ANSWERS_SF0_01_q09, (const char*)TPCH_ANSWERS_SF0_01_q10,
-    (const char*)TPCH_ANSWERS_SF0_01_q11, (const char*)TPCH_ANSWERS_SF0_01_q12,
-    (const char*)TPCH_ANSWERS_SF0_01_q13, (const char*)TPCH_ANSWERS_SF0_01_q14,
-    (const char*)TPCH_ANSWERS_SF0_01_q15, (const char*)TPCH_ANSWERS_SF0_01_q16,
-    (const char*)TPCH_ANSWERS_SF0_01_q17, (const char*)TPCH_ANSWERS_SF0_01_q18,
-    (const char*)TPCH_ANSWERS_SF0_01_q19, (const char*)TPCH_ANSWERS_SF0_01_q20,
-    (const char*)TPCH_ANSWERS_SF0_01_q21, (const char*)TPCH_ANSWERS_SF0_01_q22};
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q01), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q02),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q03), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q04),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q05), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q06),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q07), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q08),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q09), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q10),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q11), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q12),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q13), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q14),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q15), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q16),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q17), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q18),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q19), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q20),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q21), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_01_q22)};
+
 const uint8_t TPCH_ANSWERS_SF0_1_q01[] = {
     108, 95,  114, 101, 116, 117, 114, 110, 102, 108, 97,  103, 124, 108, 95,
     108, 105, 110, 101, 115, 116, 97,  116, 117, 115, 124, 115, 117, 109, 95,
@@ -13400,17 +13418,17 @@ const uint8_t TPCH_ANSWERS_SF0_1_q22[] = {
     56,  46,  48,  50,  10,  51,  49,  124, 56,  55,  124, 54,  52,  55, 51,
     55,  50,  46,  53,  48,  10,  0};
 const char* TPCH_ANSWERS_SF0_1[] = {
-    (const char*)TPCH_ANSWERS_SF0_1_q01, (const char*)TPCH_ANSWERS_SF0_1_q02,
-    (const char*)TPCH_ANSWERS_SF0_1_q03, (const char*)TPCH_ANSWERS_SF0_1_q04,
-    (const char*)TPCH_ANSWERS_SF0_1_q05, (const char*)TPCH_ANSWERS_SF0_1_q06,
-    (const char*)TPCH_ANSWERS_SF0_1_q07, (const char*)TPCH_ANSWERS_SF0_1_q08,
-    (const char*)TPCH_ANSWERS_SF0_1_q09, (const char*)TPCH_ANSWERS_SF0_1_q10,
-    (const char*)TPCH_ANSWERS_SF0_1_q11, (const char*)TPCH_ANSWERS_SF0_1_q12,
-    (const char*)TPCH_ANSWERS_SF0_1_q13, (const char*)TPCH_ANSWERS_SF0_1_q14,
-    (const char*)TPCH_ANSWERS_SF0_1_q15, (const char*)TPCH_ANSWERS_SF0_1_q16,
-    (const char*)TPCH_ANSWERS_SF0_1_q17, (const char*)TPCH_ANSWERS_SF0_1_q18,
-    (const char*)TPCH_ANSWERS_SF0_1_q19, (const char*)TPCH_ANSWERS_SF0_1_q20,
-    (const char*)TPCH_ANSWERS_SF0_1_q21, (const char*)TPCH_ANSWERS_SF0_1_q22};
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q01), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q02),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q03), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q04),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q05), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q06),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q07), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q08),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q09), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q10),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q11), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q12),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q13), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q14),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q15), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q16),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q17), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q18),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q19), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q20),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q21), CONST_CHAR_CAST(TPCH_ANSWERS_SF0_1_q22)};
 const uint8_t TPCH_ANSWERS_SF1_q01[] = {
     108, 95,  114, 101, 116, 117, 114, 110, 102, 108, 97,  103, 124, 108, 95,
     108, 105, 110, 101, 115, 116, 97,  116, 117, 115, 124, 115, 117, 109, 95,
@@ -60692,16 +60710,16 @@ const uint8_t TPCH_ANSWERS_SF1_q22[] = {
     51,  10,  51,  49,  124, 57,  50,  50,  124, 54,  56,  48,  54,  54,  55,
     48,  46,  49,  56,  10,  0};
 const char* TPCH_ANSWERS_SF1[] = {
-    (const char*)TPCH_ANSWERS_SF1_q01, (const char*)TPCH_ANSWERS_SF1_q02,
-    (const char*)TPCH_ANSWERS_SF1_q03, (const char*)TPCH_ANSWERS_SF1_q04,
-    (const char*)TPCH_ANSWERS_SF1_q05, (const char*)TPCH_ANSWERS_SF1_q06,
-    (const char*)TPCH_ANSWERS_SF1_q07, (const char*)TPCH_ANSWERS_SF1_q08,
-    (const char*)TPCH_ANSWERS_SF1_q09, (const char*)TPCH_ANSWERS_SF1_q10,
-    (const char*)TPCH_ANSWERS_SF1_q11, (const char*)TPCH_ANSWERS_SF1_q12,
-    (const char*)TPCH_ANSWERS_SF1_q13, (const char*)TPCH_ANSWERS_SF1_q14,
-    (const char*)TPCH_ANSWERS_SF1_q15, (const char*)TPCH_ANSWERS_SF1_q16,
-    (const char*)TPCH_ANSWERS_SF1_q17, (const char*)TPCH_ANSWERS_SF1_q18,
-    (const char*)TPCH_ANSWERS_SF1_q19, (const char*)TPCH_ANSWERS_SF1_q20,
-    (const char*)TPCH_ANSWERS_SF1_q21, (const char*)TPCH_ANSWERS_SF1_q22};
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q01), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q02),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q03), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q04),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q05), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q06),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q07), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q08),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q09), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q10),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q11), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q12),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q13), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q14),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q15), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q16),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q17), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q18),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q19), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q20),
+    CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q21), CONST_CHAR_CAST(TPCH_ANSWERS_SF1_q22)};
 
 } // namespace facebook::velox::tpch::dbgen
diff --git a/velox/tpch/gen/dbgen/permute.cpp b/velox/tpch/gen/dbgen/permute.cpp
index b97556d71648..48e52cd454a8 100644
--- a/velox/tpch/gen/dbgen/permute.cpp
+++ b/velox/tpch/gen/dbgen/permute.cpp
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /*
  * Copyright owned by the Transaction Processing Performance Council.
  *
@@ -32,9 +47,9 @@ void permute(long* a, int c, seed_t* seed) {
   static DSS_HUGE source;
   static long temp;
 
-  if (a != (long*)NULL) {
+  if (a != reinterpret_cast<long*>(NULL)) {
     for (i = 0; i < c; i++) {
-      RANDOM(source, (long)i, (long)(c - 1), seed);
+      RANDOM(source, static_cast<long>(i), static_cast<long>(c - 1), seed);
       temp = *(a + source);
       *(a + source) = *(a + i);
       *(a + i) = temp;
@@ -48,8 +63,8 @@ void permute_dist(distribution* d, seed_t* seed) {
   int i;
 
   if (d != NULL) {
-    if (d->permute == (long*)NULL) {
-      d->permute = (long*)malloc(sizeof(long) * DIST_SIZE(d));
+    if (d->permute == reinterpret_cast<long*>(NULL)) {
+      d->permute = reinterpret_cast<long*>(malloc(sizeof(long) * DIST_SIZE(d)));
       MALLOC_CHECK(d->permute);
     }
     for (i = 0; i < DIST_SIZE(d); i++)
diff --git a/velox/tpch/gen/dbgen/rnd.cpp b/velox/tpch/gen/dbgen/rnd.cpp
index 52f6ee0f5ae3..4da6231314b6 100644
--- a/velox/tpch/gen/dbgen/rnd.cpp
+++ b/velox/tpch/gen/dbgen/rnd.cpp
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /*
  * Copyright owned by the Transaction Processing Performance Council.
  *
@@ -40,7 +55,6 @@ void dss_random(DSS_HUGE* tgt, DSS_HUGE lower, DSS_HUGE upper, seed_t* seed) {
 }
 
 void row_start(int t, DBGenContext* ctx) {
-  (void)t;
   int i;
   for (i = 0; i <= MAX_STREAM; i++)
     ctx->Seed[i].usage = 0;
@@ -138,19 +152,21 @@ UnifInt(DSS_HUGE nLow, DSS_HUGE nHigh, seed_t* seed)
 {
   double dRange;
   DSS_HUGE nTemp;
-  int32_t nLow32 = (int32_t)nLow, nHigh32 = (int32_t)nHigh;
+  int32_t nLow32 = static_cast<int32_t>(nLow),
+          nHigh32 = static_cast<int32_t>(nHigh);
 
   if ((nHigh == MAX_LONG) && (nLow == 0)) {
-    dRange = (double)((DSS_HUGE)(nHigh32 - nLow32) + 1);
+    dRange = static_cast<double>(static_cast<DSS_HUGE>(nHigh32 - nLow32) + 1);
   } else {
-    dRange = (double)(nHigh - nLow + 1);
+    dRange = static_cast<double>(nHigh - nLow + 1);
   }
 
   seed->value = NextRand(seed->value);
 #ifdef RNG_TEST
   seed->nCalls += 1;
 #endif
-  nTemp = (DSS_HUGE)(((double)seed->value / DBGenContext::dM) * (dRange));
+  nTemp = static_cast<DSS_HUGE>(
+      (static_cast<double>(seed->value) / DBGenContext::dM) * (dRange));
   return (nLow + nTemp);
 }
 
diff --git a/velox/tpch/gen/dbgen/rng64.cpp b/velox/tpch/gen/dbgen/rng64.cpp
index b6054c8a84db..2a2d63714ace 100644
--- a/velox/tpch/gen/dbgen/rng64.cpp
+++ b/velox/tpch/gen/dbgen/rng64.cpp
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /*
  * Copyright owned by the Transaction Processing Performance Council.
  *
@@ -94,8 +109,8 @@ void dss_random64(DSS_HUGE* tgt, DSS_HUGE nLow, DSS_HUGE nHigh, seed_t* seed) {
 
 DSS_HUGE
 NextRand64(DSS_HUGE nSeed) {
-  DSS_HUGE a = (unsigned DSS_HUGE)RNG_A;
-  DSS_HUGE c = (unsigned DSS_HUGE)RNG_C;
+  DSS_HUGE a = static_cast<unsigned DSS_HUGE>(RNG_A);
+  DSS_HUGE c = static_cast<unsigned DSS_HUGE>(RNG_C);
   nSeed = (nSeed * a + c); /* implicitely truncated to 64bits */
 
   return (nSeed);
diff --git a/velox/tpch/gen/dbgen/speed_seed.cpp b/velox/tpch/gen/dbgen/speed_seed.cpp
index 7df3dc9edda8..196bdc77ddcb 100644
--- a/velox/tpch/gen/dbgen/speed_seed.cpp
+++ b/velox/tpch/gen/dbgen/speed_seed.cpp
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /*
  * Copyright owned by the Transaction Processing Performance Council.
  *
@@ -75,7 +90,7 @@ void NthElement(DSS_HUGE N, DSS_HUGE* StartSeed) {
     fprintf(stderr, "%c\b", lnoise[i]);
   }
   Mult = Multiplier;
-  Z = (DSS_HUGE)*StartSeed;
+  Z = static_cast<DSS_HUGE>(*StartSeed);
   while (N > 0) {
     if (N % 2 != 0) /* testing for oddness, this seems portable */
       Z = (Mult * Z) % Modulus;
@@ -105,7 +120,6 @@ void fake_tpch_a_rnd(int min, int max, seed_t* seed) {
 }
 
 long sd_part(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
   int i;
 
   for (i = P_MFG_SD; i <= P_CNTR_SD; i++)
@@ -141,7 +155,6 @@ long sd_line(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
 }
 
 long sd_order(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
   ADVANCE_STREAM(&ctx->Seed[O_LCNT_SD], skip_count);
   /*
       if (ctx->scale_factor >= 30000)
@@ -159,8 +172,6 @@ long sd_order(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
 }
 
 long sd_psupp(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
-
   int j;
 
   for (j = 0; j < SUPP_PER_PART; j++) {
@@ -173,8 +184,6 @@ long sd_psupp(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
 }
 
 long sd_cust(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
-
   ADVANCE_STREAM(&ctx->Seed[C_ADDR_SD], skip_count * 9);
   ADVANCE_STREAM(&ctx->Seed[C_CMNT_SD], skip_count * 2);
   ADVANCE_STREAM(&ctx->Seed[C_NTRG_SD], skip_count);
@@ -185,8 +194,6 @@ long sd_cust(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
 }
 
 long sd_supp(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
-
   ADVANCE_STREAM(&ctx->Seed[S_NTRG_SD], skip_count);
   ADVANCE_STREAM(&ctx->Seed[S_PHNE_SD], 3L * skip_count);
   ADVANCE_STREAM(&ctx->Seed[S_ABAL_SD], skip_count);
@@ -201,16 +208,12 @@ long sd_supp(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
 }
 
 long sd_nation(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
-
   ADVANCE_STREAM(&ctx->Seed[N_CMNT_SD], skip_count * 2);
 
   return (0L);
 }
 
 long sd_region(int child, DSS_HUGE skip_count, DBGenContext* ctx) {
-  (void)child;
-
   ADVANCE_STREAM(&ctx->Seed[R_CMNT_SD], skip_count * 2);
 
   return (0L);
diff --git a/velox/tpch/gen/dbgen/text.cpp b/velox/tpch/gen/dbgen/text.cpp
index a99e7a4187d3..a0954fb92719 100644
--- a/velox/tpch/gen/dbgen/text.cpp
+++ b/velox/tpch/gen/dbgen/text.cpp
@@ -259,7 +259,7 @@ void init_text_pool(long bSize, DBGenContext* ctx) {
   gen_index(prepositions_index, &prepositions);
 
   txtBufferSize = bSize;
-  szTextPool = (char*)malloc(bSize + 1 + 100);
+  szTextPool = reinterpret_cast<char*>(malloc(bSize + 1 + 100));
   MALLOC_CHECK(szTextPool);
   memset(szTextPool, 0, bSize + 1 + 100);
 
@@ -285,7 +285,7 @@ void dbg_text(char* tgt, int min, int max, seed_t* seed) {
 
   RANDOM(hgOffset, 0, txtBufferSize - max, seed);
   RANDOM(hgLength, min, max, seed);
-  strncpy(&tgt[0], &szTextPool[hgOffset], (int)hgLength);
+  strncpy(&tgt[0], &szTextPool[hgOffset], static_cast<int>(hgLength));
   tgt[hgLength] = '\0';
 
   return;