Skip to content

Commit

Permalink
feat: binding interval convert to python timedelta
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Jan 7, 2025
1 parent 53417f0 commit 5e9adf2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bindings/python/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use chrono::Duration;
use std::sync::Arc;

use chrono::{NaiveDate, NaiveDateTime};
Expand Down Expand Up @@ -102,7 +103,14 @@ impl<'py> IntoPyObject<'py> for Value {
databend_driver::Value::Variant(s) => s.into_bound_py_any(py)?,
databend_driver::Value::Geometry(s) => s.into_bound_py_any(py)?,
databend_driver::Value::Geography(s) => s.into_bound_py_any(py)?,
databend_driver::Value::Interval(s) => s.into_bound_py_any(py)?,
databend_driver::Value::Interval(s) => {
let value = databend_driver::Interval::from_string(&s)?;
let total_micros = (value.months as i64) * 30 * 86400000000
+ (value.days as i64) * 86400000000
+ value.micros;
let s = Duration::microseconds(total_micros);
s.into_bound_py_any(py)?
}
};
Ok(val)
}
Expand Down

0 comments on commit 5e9adf2

Please sign in to comment.