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

fix: do not format sql on send #274

Merged
merged 3 commits into from
Oct 25, 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
8 changes: 3 additions & 5 deletions cli/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use tokio::io::AsyncWriteExt;
use tokio::time::Instant;
use tokio_stream::StreamExt;

use crate::ast::format_query;
use crate::ast::{TokenKind, Tokenizer};
use crate::config::Settings;
use crate::config::TimeOption;
Expand Down Expand Up @@ -260,7 +259,7 @@ impl Session {
}
TokenKind::Newline => {
in_comment = false;
self.query.push(' ');
self.query.push('\n');
}
TokenKind::CommentBlockStart => {
if !self.in_comment_block {
Expand Down Expand Up @@ -312,12 +311,11 @@ impl Session {
return Ok(Some(ServerStats::default()));
}

let formatted_query = format_query(query);
let start = Instant::now();
let kind = QueryKind::from(query);
match (kind, is_repl) {
(QueryKind::Update, false) => {
let affected = self.conn.exec(&formatted_query).await?;
let affected = self.conn.exec(query).await?;
if is_repl {
if affected > 0 {
eprintln!(
Expand Down Expand Up @@ -356,7 +354,7 @@ impl Session {
}
self.conn.get_files(&args[1], &args[2]).await?
}
_ => self.conn.query_iter_ext(&formatted_query).await?,
_ => self.conn.query_iter_ext(query).await?,
};

let mut displayer = FormatDisplay::new(
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/01-put.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/tmp/a1.txt SUCCESS 5
/tmp/a2.txt SUCCESS 5
/tmp/edf/a1.txt SUCCESS 5
/tmp/edf/a2.txt SUCCESS 5
/tmp/abc/books.parquet SUCCESS 1882
/tmp/edf/books.parquet SUCCESS 1882
Transaction Processing Jim Gray 1992
Readings in Database Systems Michael Stonebraker 2004
28 changes: 25 additions & 3 deletions cli/tests/01-put.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,30 @@
echo "DROP STAGE IF EXISTS ss_temp" | ${BENDSQL}
echo "CREATE STAGE ss_temp" | ${BENDSQL}

echo "ABCD" >/tmp/a1.txt
echo "ABCD" >/tmp/a2.txt
cat <<SQL | ${BENDSQL}
DROP TABLE IF EXISTS books;
CREATE TABLE books
(
title VARCHAR,
author VARCHAR,
date VARCHAR
);
SQL

echo 'put fs:///tmp/a*.txt @ss_temp/abc' | ${BENDSQL}
cat <<SQL | ${BENDSQL}
SELECT * FROM books;
SQL

mkdir -p /tmp/abc
cp "${PWD}/cli/tests/data/books.parquet" /tmp/abc/books.parquet

echo "put fs:///tmp/abc/b*.parquet @ss_temp/abc/" | ${BENDSQL}
echo 'get @ss_temp/abc fs:///tmp/edf' | ${BENDSQL}

cat <<SQL | ${BENDSQL}
COPY INTO books FROM @ss_temp/abc/ files=('books.parquet') FILE_FORMAT = (TYPE = PARQUET);
SQL

cat <<SQL | ${BENDSQL}
SELECT * FROM books LIMIT 2;
SQL
Binary file added cli/tests/data/books.parquet
Binary file not shown.