Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nexus/analyzer: remove unnecessary lazy_static #697

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion nexus/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion nexus/analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ anyhow = "1.0"
async-trait = "0.1"
catalog = { path = "../catalog" }
flow-rs = { path = "../flow-rs" }
lazy_static = "1.4"
pem = "3.0"
pt = { path = "../pt" }
sqlparser = { path = "../sqlparser-rs", features = ["visitor"] }
Expand Down
155 changes: 76 additions & 79 deletions nexus/analyzer/src/qrep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum QRepOptionType {
name: &'static str,
default_val: Option<&'static str>,
required: bool,
accepted_values: Option<Vec<&'static str>>,
accepted_values: Option<&'static [&'static str]>,
},
Int {
name: &'static str,
Expand All @@ -26,90 +26,87 @@ enum QRepOptionType {
},
}

lazy_static::lazy_static! {
static ref QREP_OPTIONS: Vec<QRepOptionType> = {
vec![
QRepOptionType::String {
name: "destination_table_name",
default_val: None,
required: true,
accepted_values: None,
},
QRepOptionType::String {
name: "watermark_column",
default_val: None,
required: false,
accepted_values: None,
},
QRepOptionType::String {
name: "watermark_table_name",
default_val: None,
required: false,
accepted_values: None,
},
QRepOptionType::String {
name: "mode",
default_val: Some("append"),
required: false,
accepted_values: Some(vec!["upsert", "append", "overwrite"]),
},
QRepOptionType::StringArray {
name: "unique_key_columns",
},
QRepOptionType::String {
name: "sync_data_format",
default_val: Some("default"),
required: false,
accepted_values: Some(vec!["default", "avro"]),
},
QRepOptionType::String {
name: "staging_path",
default_val: None,
required: false,
accepted_values: None,
},
QRepOptionType::Int {
name: "parallelism",
min_value: Some(1),
default_value: 2,
required: false,
},
QRepOptionType::Int {
name: "refresh_interval",
min_value: Some(10),
default_value: 10,
required: false,
},
QRepOptionType::Int {
name: "num_rows_per_partition",
min_value: Some(1),
default_value: 50000,
required: true,
},
QRepOptionType::Boolean {
name: "initial_copy_only",
default_value: false,
required: false,
},
QRepOptionType::Boolean {
name: "setup_watermark_table_on_destination",
default_value: false,
required: false
},
QRepOptionType::Boolean {
name: "dst_table_full_resync",
default_value: false,
required: false
}]
};
}
const QREP_OPTIONS: &[QRepOptionType] = &[
QRepOptionType::String {
name: "destination_table_name",
default_val: None,
required: true,
accepted_values: None,
},
QRepOptionType::String {
name: "watermark_column",
default_val: None,
required: false,
accepted_values: None,
},
QRepOptionType::String {
name: "watermark_table_name",
default_val: None,
required: false,
accepted_values: None,
},
QRepOptionType::String {
name: "mode",
default_val: Some("append"),
required: false,
accepted_values: Some(&["upsert", "append", "overwrite"]),
},
QRepOptionType::StringArray {
name: "unique_key_columns",
},
QRepOptionType::String {
name: "sync_data_format",
default_val: Some("default"),
required: false,
accepted_values: Some(&["default", "avro"]),
},
QRepOptionType::String {
name: "staging_path",
default_val: None,
required: false,
accepted_values: None,
},
QRepOptionType::Int {
name: "parallelism",
min_value: Some(1),
default_value: 2,
required: false,
},
QRepOptionType::Int {
name: "refresh_interval",
min_value: Some(10),
default_value: 10,
required: false,
},
QRepOptionType::Int {
name: "num_rows_per_partition",
min_value: Some(1),
default_value: 50000,
required: true,
},
QRepOptionType::Boolean {
name: "initial_copy_only",
default_value: false,
required: false,
},
QRepOptionType::Boolean {
name: "setup_watermark_table_on_destination",
default_value: false,
required: false
},
QRepOptionType::Boolean {
name: "dst_table_full_resync",
default_value: false,
required: false
}
];

pub fn process_options(
mut raw_opts: HashMap<&str, &SqlValue>,
) -> anyhow::Result<HashMap<String, Value>> {
let mut opts: HashMap<String, Value> = HashMap::new();

for opt_type in &*QREP_OPTIONS {
for opt_type in QREP_OPTIONS {
match opt_type {
QRepOptionType::String {
name,
Expand Down
Loading