-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][Server] Add metadata lineage api (#423)
- Loading branch information
Showing
29 changed files
with
683 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ector/datavines-connector-api/src/main/java/io/datavines/connector/api/LineageParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api; | ||
|
||
import io.datavines.common.utils.StringUtils; | ||
import io.datavines.connector.api.entity.ScriptMetadata; | ||
import io.datavines.connector.api.entity.StatementMetadata; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public class LineageParser { | ||
|
||
public static ScriptMetadata parseScript(String script, StatementSplitter statementSplitter, StatementParser statementParser) { | ||
if (StringUtils.isEmpty(script)) { | ||
return null; | ||
} | ||
|
||
ScriptMetadata scriptMetadata = new ScriptMetadata(); | ||
scriptMetadata.setScript(script); | ||
List<String> statements = statementSplitter.splitStatements(script); | ||
|
||
if (CollectionUtils.isEmpty(statements)) { | ||
return null; | ||
} | ||
|
||
for (int i=0; i<statements.size(); i++) { | ||
StatementMetadata statementMetadata = new StatementMetadata(); | ||
statementMetadata.setStatementIndex(i); | ||
statementMetadata.setStatementText(statements.get(i)); | ||
statementMetadata.setStatementParseStartTime(LocalDateTime.now()); | ||
statementMetadata.setStatementMetadataFragment(statementParser.parseStatement(statements.get(i))); | ||
statementMetadata.setStatementParseEndTime(LocalDateTime.now()); | ||
scriptMetadata.addStatementMetadata(statementMetadata); | ||
} | ||
|
||
return scriptMetadata; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...tor/datavines-connector-api/src/main/java/io/datavines/connector/api/StatementParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api; | ||
|
||
import io.datavines.connector.api.entity.StatementMetadataFragment; | ||
|
||
public interface StatementParser { | ||
|
||
StatementMetadataFragment parseStatement(String statement); | ||
} |
24 changes: 24 additions & 0 deletions
24
...r/datavines-connector-api/src/main/java/io/datavines/connector/api/StatementSplitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api; | ||
|
||
import java.util.List; | ||
|
||
public interface StatementSplitter { | ||
|
||
List<String> splitStatements(String body) ; | ||
} |
31 changes: 31 additions & 0 deletions
31
...atavines-connector-api/src/main/java/io/datavines/connector/api/entity/ColumnLineage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class ColumnLineage { | ||
|
||
private List<String> inputColumns; | ||
|
||
private List<String> outputColumns; | ||
} |
22 changes: 22 additions & 0 deletions
22
...ines-connector-api/src/main/java/io/datavines/connector/api/entity/MetaDataConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api.entity; | ||
|
||
public class MetaDataConstants { | ||
|
||
public final static String UNKNOWN_STATEMENT_TYPE = "UNKNOWN"; | ||
} |
37 changes: 37 additions & 0 deletions
37
...tavines-connector-api/src/main/java/io/datavines/connector/api/entity/ScriptMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api.entity; | ||
|
||
import lombok.Data; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Data | ||
public class ScriptMetadata { | ||
|
||
private String script; | ||
|
||
private List<StatementMetadata> statementMetadataList; | ||
|
||
public void addStatementMetadata(StatementMetadata statementMetadata) { | ||
if (CollectionUtils.isEmpty(statementMetadataList)) { | ||
statementMetadataList = new ArrayList<>(); | ||
} | ||
statementMetadataList.add(statementMetadata); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ines-connector-api/src/main/java/io/datavines/connector/api/entity/StatementMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api.entity; | ||
|
||
import lombok.Data; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
public class StatementMetadata { | ||
|
||
private int statementIndex; | ||
|
||
private String statementText; | ||
|
||
private StatementMetadataFragment statementMetadataFragment; | ||
|
||
private LocalDateTime statementParseStartTime; | ||
|
||
private LocalDateTime statementParseEndTime; | ||
} |
33 changes: 33 additions & 0 deletions
33
...nector-api/src/main/java/io/datavines/connector/api/entity/StatementMetadataFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.api.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class StatementMetadataFragment { | ||
|
||
private List<String> inputTables; | ||
|
||
private List<String> outputTables; | ||
|
||
private List<ColumnLineage> columnLineageList; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...es-connector-jdbc/src/main/java/io/datavines/connector/plugin/DefaultStatementParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.plugin; | ||
|
||
import io.datavines.connector.api.StatementParser; | ||
import io.datavines.connector.api.entity.StatementMetadataFragment; | ||
|
||
public class DefaultStatementParser implements StatementParser { | ||
|
||
@Override | ||
public StatementMetadataFragment parseStatement(String statement) { | ||
return null; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-connector-jdbc/src/main/java/io/datavines/connector/plugin/DefaultStatementSplitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.datavines.connector.plugin; | ||
|
||
import io.datavines.common.utils.StringUtils; | ||
import io.datavines.connector.api.StatementSplitter; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class DefaultStatementSplitter implements StatementSplitter { | ||
|
||
@Override | ||
public List<String> splitStatements(String body) { | ||
|
||
String DELIMITER = ";"; | ||
return StringUtils.isEmpty(body) ? null : Arrays.asList(body.split(DELIMITER)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.