This commit is contained in:
Chen Xu 2022-07-18 03:52:54 +08:00
Родитель b3657f0a22
Коммит a730e8d4e9
5 изменённых файлов: 34 добавлений и 73 удалений

Просмотреть файл

@ -125,16 +125,8 @@ pub struct ProjectAttributes {
pub struct SourceAttributes {
pub qualified_name: String,
pub name: String,
#[oai(skip_serializing_if = "Option::is_none")]
pub path: Option<String>,
#[oai(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[oai(skip_serializing_if = "Option::is_none")]
pub dbtable: Option<String>,
#[oai(skip_serializing_if = "Option::is_none")]
pub query: Option<String>,
#[oai(skip_serializing_if = "Option::is_none")]
pub auth: Option<String>,
#[oai(default, flatten)]
pub options: HashMap<String, String>,
#[oai(skip_serializing_if = "Option::is_none")]
pub preprocessing: Option<String>,
#[oai(skip_serializing_if = "Option::is_none")]
@ -196,24 +188,28 @@ pub enum EntityAttributes {
impl From<registry_provider::EntityProperty> for EntityAttributes {
fn from(v: registry_provider::EntityProperty) -> Self {
match v.attributes {
registry_provider::Attributes::AnchorFeature(attr) => Self::AnchorFeature(AnchorFeatureAttributes {
qualified_name: v.qualified_name,
name: v.name,
tags: v.tags,
type_: attr.type_.into(),
transformation: attr.transformation.into(),
key: attr.key.into_iter().map(|e| e.into()).collect(),
}),
registry_provider::Attributes::DerivedFeature(attr) => Self::DerivedFeature(DerivedFeatureAttributes {
qualified_name: v.qualified_name,
name: v.name,
tags: v.tags,
type_: attr.type_.into(),
transformation: attr.transformation.into(),
key: attr.key.into_iter().map(|e| e.into()).collect(),
input_anchor_features: Default::default(),
input_derived_features: Default::default(),
}),
registry_provider::Attributes::AnchorFeature(attr) => {
Self::AnchorFeature(AnchorFeatureAttributes {
qualified_name: v.qualified_name,
name: v.name,
tags: v.tags,
type_: attr.type_.into(),
transformation: attr.transformation.into(),
key: attr.key.into_iter().map(|e| e.into()).collect(),
})
}
registry_provider::Attributes::DerivedFeature(attr) => {
Self::DerivedFeature(DerivedFeatureAttributes {
qualified_name: v.qualified_name,
name: v.name,
tags: v.tags,
type_: attr.type_.into(),
transformation: attr.transformation.into(),
key: attr.key.into_iter().map(|e| e.into()).collect(),
input_anchor_features: Default::default(),
input_derived_features: Default::default(),
})
}
registry_provider::Attributes::Anchor => Self::Anchor(AnchorAttributes {
qualified_name: v.qualified_name,
name: v.name,
@ -225,16 +221,12 @@ impl From<registry_provider::EntityProperty> for EntityAttributes {
qualified_name: v.qualified_name,
name: v.name,
tags: v.tags,
path: attr.path,
url: attr.url,
dbtable: attr.dbtable,
query: attr.query,
auth: attr.auth,
options: attr.options,
preprocessing: attr.preprocessing,
event_timestamp_column: attr.event_timestamp_column,
timestamp_format: attr.timestamp_format,
type_: attr.type_,
}),
}),
registry_provider::Attributes::Project => Self::Project(ProjectAttributes {
qualified_name: v.qualified_name,
name: v.name,

Просмотреть файл

@ -60,19 +60,7 @@ pub struct SourceDef {
pub source_type: String,
#[oai(default)]
#[serde(default)]
pub path: Option<String>,
#[oai(default)]
#[serde(default)]
pub url: Option<String>,
#[oai(default)]
#[serde(default)]
pub dbtable: Option<String>,
#[oai(default)]
#[serde(default)]
pub query: Option<String>,
#[oai(default)]
#[serde(default)]
pub auth: Option<String>,
pub options: HashMap<String, String>,
#[oai(default)]
#[serde(default)]
pub event_timestamp_column: Option<String>,
@ -98,11 +86,7 @@ impl TryInto<registry_provider::SourceDef> for SourceDef {
qualified_name: self.qualified_name,
name: self.name,
source_type: self.source_type,
path: self.path,
url: self.url,
dbtable: self.dbtable,
query: self.query,
auth: self.auth,
options: self.options,
event_timestamp_column: self.event_timestamp_column,
timestamp_format: self.timestamp_format,
preprocessing: self.preprocessing,

Просмотреть файл

@ -1,4 +1,4 @@
use std::fmt::Debug;
use std::{fmt::Debug, collections::HashMap};
use std::hash::Hash;
use serde::{Deserialize, Serialize};
@ -142,21 +142,13 @@ pub struct SourceAttributes {
#[serde(rename = "type")]
pub type_: String,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub path: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub dbtable: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub query: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub auth: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub preprocessing: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub event_timestamp_column: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub timestamp_format: Option<String>,
#[serde(flatten, default)]
pub options: HashMap<String, String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]

Просмотреть файл

@ -22,11 +22,8 @@ pub struct SourceDef {
pub qualified_name: String,
#[serde(rename = "type")]
pub source_type: String,
pub path: Option<String>,
pub url: Option<String>,
pub dbtable: Option<String>,
pub query: Option<String>,
pub auth: Option<String>,
#[serde(flatten)]
pub options: HashMap<String, String>,
pub event_timestamp_column: Option<String>,
pub timestamp_format: Option<String>,
pub preprocessing: Option<String>,

Просмотреть файл

@ -78,11 +78,7 @@ impl EntityPropMutator for EntityProperty {
labels: Default::default(),
tags: definition.tags.to_owned(),
attributes: Attributes::Source(SourceAttributes {
path: definition.path.to_owned(),
url: definition.url.to_owned(),
dbtable: definition.dbtable.to_owned(),
query: definition.query.to_owned(),
auth: definition.auth.to_owned(),
options: definition.options.to_owned(),
preprocessing: definition.preprocessing.to_owned(),
event_timestamp_column: definition.event_timestamp_column.to_owned(),
timestamp_format: definition.timestamp_format.to_owned(),