mod common; use snowflake_connector_rs::Result; #[tokio::test] async fn test_decode_naive_date() -> Result<()> { // Arrange let client = common::connect()?; let session = client.create_session().await?; // Act let query = "SELECT '2020-01-01'::DATE AS date"; let rows = session.query(query).await?; // Assert assert_eq!(rows.len(), 1); assert_eq!( rows[0].get::("DATE")?, chrono::NaiveDate::from_ymd_opt(2020, 1, 1).unwrap() ); Ok(()) } #[tokio::test] async fn test_basic_operations() -> Result<()> { // Connect to Snowflake let client = common::connect()?; let session = client.create_session().await?; // Create a temporary table let query = "CREATE TEMPORARY TABLE example (id NUMBER, value STRING)"; let rows = session.query(query).await?; assert_eq!(rows.len(), 1); assert_eq!( rows[0].get::("STATUS")?, "Table EXAMPLE successfully created." ); // Insert some data let query = "INSERT INTO example (id, value) VALUES (1, 'hello'), (2, 'world')"; let rows = session.query(query).await?; assert_eq!(rows.len(), 1); assert_eq!(rows[0].get::("NUMBER OF ROWS INSERTED")?, 2); // Select the data back let query = "SELECT * FROM example ORDER BY id"; let rows = session.query(query).await?; assert_eq!(rows.len(), 2); assert_eq!(rows[0].get::("ID")?, 1); assert_eq!(rows[0].get::("VALUE")?, "hello"); assert_eq!(rows[1].get::("ID")?, 2); assert_eq!(rows[1].get::("VALUE")?, "world"); Ok(()) }