Skip to content

Commit c3825cd

Browse files
committed
Merge branch 'enterprise-security-features'
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents bdfb239 + a58a4cd commit c3825cd

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-postgres-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ datafusion = { workspace = true, default-features = true, features = ["avro"] }
1717
tokio = { workspace = true, features = ["full"] }
1818
datafusion-postgres = { path = "../datafusion-postgres", version = "0.6.1" }
1919
structopt = { version = "0.3", default-features = false }
20+
log = "0.4"
2021
env_logger = "0.11"

datafusion-postgres-cli/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use datafusion::execution::options::{
88
use datafusion::prelude::{SessionConfig, SessionContext};
99
use datafusion_postgres::pg_catalog::setup_pg_catalog;
1010
use datafusion_postgres::{serve, ServerOptions}; // Assuming the crate name is `datafusion_postgres`
11+
use log::info;
1112
use structopt::StructOpt;
1213

1314
#[derive(Debug, StructOpt)]
@@ -129,7 +130,7 @@ async fn setup_session_context(
129130
.register_csv(table_name, table_path, CsvReadOptions::default())
130131
.await
131132
.map_err(|e| format!("Failed to register CSV table '{table_name}': {e}"))?;
132-
println!("Loaded {table_path} as table {table_name}");
133+
info!("Loaded {table_path} as table {table_name}");
133134
}
134135

135136
// Register JSON tables
@@ -138,7 +139,7 @@ async fn setup_session_context(
138139
.register_json(table_name, table_path, NdJsonReadOptions::default())
139140
.await
140141
.map_err(|e| format!("Failed to register JSON table '{table_name}': {e}"))?;
141-
println!("Loaded {table_path} as table {table_name}");
142+
info!("Loaded {table_path} as table {table_name}");
142143
}
143144

144145
// Register Arrow tables
@@ -151,7 +152,7 @@ async fn setup_session_context(
151152
.register_arrow(table_name, table_path, ArrowReadOptions::default())
152153
.await
153154
.map_err(|e| format!("Failed to register Arrow table '{table_name}': {e}"))?;
154-
println!("Loaded {table_path} as table {table_name}");
155+
info!("Loaded {table_path} as table {table_name}");
155156
}
156157

157158
// Register Parquet tables
@@ -164,7 +165,7 @@ async fn setup_session_context(
164165
.register_parquet(table_name, table_path, ParquetReadOptions::default())
165166
.await
166167
.map_err(|e| format!("Failed to register Parquet table '{table_name}': {e}"))?;
167-
println!("Loaded {table_path} as table {table_name}");
168+
info!("Loaded {table_path} as table {table_name}");
168169
}
169170

170171
// Register Avro tables
@@ -173,7 +174,7 @@ async fn setup_session_context(
173174
.register_avro(table_name, table_path, AvroReadOptions::default())
174175
.await
175176
.map_err(|e| format!("Failed to register Avro table '{table_name}': {e}"))?;
176-
println!("Loaded {table_path} as table {table_name}");
177+
info!("Loaded {table_path} as table {table_name}");
177178
}
178179

179180
// Register pg_catalog

datafusion-postgres/src/auth.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashMap;
22
use std::sync::Arc;
33

44
use async_trait::async_trait;
5+
use log::warn;
56
use pgwire::api::auth::{AuthSource, LoginInfo, Password};
67
use pgwire::error::{PgWireError, PgWireResult};
78
use tokio::sync::RwLock;
@@ -175,7 +176,8 @@ impl AuthManager {
175176

176177
// Create predefined roles
177178
if let Err(e) = auth_manager_spawn.create_predefined_roles().await {
178-
eprintln!("Failed to create predefined roles: {e:?}");
179+
warn!("Failed to create predefined roles: {e:?}");
180+
179181
}
180182
}
181183
});

datafusion-postgres/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use datafusion::prelude::SessionContext;
99

1010
pub mod auth;
1111
use getset::{Getters, Setters, WithSetters};
12-
12+
use log::{info, warn};
1313
use pgwire::tokio::process_socket;
1414
use rustls_pemfile::{certs, pkcs8_private_keys};
1515
use rustls_pki_types::{CertificateDer, PrivateKeyDer};
@@ -86,26 +86,26 @@ pub async fn serve(
8686
if let (Some(cert_path), Some(key_path)) = (&opts.tls_cert_path, &opts.tls_key_path) {
8787
match setup_tls(cert_path, key_path) {
8888
Ok(acceptor) => {
89-
println!("TLS enabled using cert: {cert_path} and key: {key_path}");
89+
info!("TLS enabled using cert: {cert_path} and key: {key_path}");
9090
Some(acceptor)
9191
}
9292
Err(e) => {
93-
eprintln!("Failed to setup TLS: {e}. Running without encryption.");
93+
warn!("Failed to setup TLS: {e}. Running without encryption.");
9494
None
9595
}
9696
}
9797
} else {
98-
println!("TLS not configured. Running without encryption.");
98+
info!("TLS not configured. Running without encryption.");
9999
None
100100
};
101101

102102
// Bind to the specified host and port
103103
let server_addr = format!("{}:{}", opts.host, opts.port);
104104
let listener = TcpListener::bind(&server_addr).await?;
105105
if tls_acceptor.is_some() {
106-
println!("Listening on {server_addr} with TLS encryption");
106+
info!("Listening on {server_addr} with TLS encryption");
107107
} else {
108-
println!("Listening on {server_addr} (unencrypted)");
108+
info!("Listening on {server_addr} (unencrypted)");
109109
}
110110

111111
// Accept incoming connections
@@ -117,13 +117,13 @@ pub async fn serve(
117117
// Connection accepted from {addr} - log appropriately based on your logging strategy
118118

119119
tokio::spawn(async move {
120-
if let Err(_e) = process_socket(socket, tls_acceptor_ref, factory_ref).await {
121-
// Log error or handle appropriately based on your logging strategy
120+
if let Err(e) = process_socket(socket, tls_acceptor_ref, factory_ref).await {
121+
warn!("Error processing socket: {e}");
122122
}
123123
});
124124
}
125125
Err(e) => {
126-
eprintln!("Error accept socket: {e}");
126+
warn!("Error accept socket: {e}");
127127
}
128128
}
129129
}

0 commit comments

Comments
 (0)