-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::{Context, Presto, PrestoTy}; | ||
use serde::de::DeserializeSeed; | ||
use serde::{Deserialize, Deserializer}; | ||
use serde_json::Value; | ||
|
||
impl Presto for Value { | ||
type ValueType<'a> = &'a Value; | ||
type Seed<'a, 'de> = ValueSeed; | ||
|
||
fn value(&self) -> Self::ValueType<'_> { | ||
self | ||
} | ||
|
||
fn ty() -> PrestoTy { | ||
PrestoTy::Json | ||
} | ||
|
||
fn seed<'a, 'de>(ctx: &'a Context<'a>) -> Self::Seed<'a, 'de> { | ||
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, stable)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, nightly)
Check warning on line 18 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, nightly)
|
||
ValueSeed | ||
} | ||
|
||
fn empty() -> Self { | ||
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (ubuntu-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (windows-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, stable)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, nightly)
Check warning on line 22 in src/types/json.rs GitHub Actions / build_and_test (macos-latest, nightly)
|
||
Value::empty() | ||
} | ||
} | ||
|
||
pub struct ValueSeed; | ||
|
||
impl<'de> DeserializeSeed<'de> for ValueSeed { | ||
type Value = Value; | ||
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
<Value as Deserialize<'de>>::deserialize(deserializer) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"columns": [ | ||
{ | ||
"name": "a", | ||
"type": "json", | ||
"typeSignature": { | ||
"rawType": "json", | ||
"typeArguments": [], | ||
"literalArguments": [], | ||
"arguments": [] | ||
} | ||
} | ||
], | ||
"data": [ | ||
[ | ||
"abc" | ||
] | ||
] | ||
} |