Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SQL Provenance
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
haoyuz3
SQL Provenance
Commits
dfbf46ce
Commit
dfbf46ce
authored
4 years ago
by
Haoyu Z
Browse files
Options
Downloads
Patches
Plain Diff
debug
parent
bd05b7b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
provsql/src/provenance.py
+3
-7
3 additions, 7 deletions
provsql/src/provenance.py
provsql/src/provenanceUtils.py
+60
-39
60 additions, 39 deletions
provsql/src/provenanceUtils.py
with
63 additions
and
46 deletions
provsql/src/provenance.py
+
3
−
7
View file @
dfbf46ce
...
...
@@ -74,14 +74,10 @@ def preprocess_query(query, cur, conn):
#fs: [formula1, formula2, ...]
def
process_formula
(
fs
,
tables
):
elements
=
[]
base_formula
=
ut
.
baseFormula
(
fs
[
0
])
for
i
,
formula
in
enumerate
(
fs
):
nf
,
idx
=
ut
.
remove1sAndAddTablename
(
formula
,
tables
[
i
])
elements
.
append
(((
nf
,
idx
)))
elements
.
sort
(
key
=
operator
.
itemgetter
(
1
))
formula_tmp
=
[
x
[
0
]
for
x
in
elements
]
output
=
"
"
.
join
(
formula_tmp
)
return
output
base_formula
=
ut
.
remove1sAndAddTablename
(
formula
,
tables
[
i
],
base_formula
)
return
base_formula
def
get_header
(
query
):
parsed
=
sp
.
parse
(
query
)[
0
]
...
...
This diff is collapsed.
Click to expand it.
provsql/src/provenanceUtils.py
+
60
−
39
View file @
dfbf46ce
...
...
@@ -2,52 +2,73 @@ def commitAndExecute(conn, cur, command):
cur
.
execute
(
command
)
conn
.
commit
()
#
find the
formula
and return it with the index it should be in the real formula
def
find
Formula
(
formula
):
mylis
t
=
[
"
⊕
"
,
"
⊗
"
,
"
⊖
"
,
"
𝟙
"
]
#
Return
formula
composed with 𝟙.
def
base
Formula
(
formula
):
charse
t
=
[
"
⊕
"
,
"
⊗
"
,
"
⊖
"
,
"
𝟙
"
,
"
"
,
"
(
"
,
"
)
"
]
output
=
""
state
=
"
before first character
"
idx
=
0
for
i
,
char
in
enumerate
(
formula
):
if
(
char
in
mylist
or
char
in
[
"
(
"
,
"
)
"
,
"
"
])
and
state
==
"
before first character
"
:
if
char
==
"
𝟙
"
:
idx
+=
1
continue
state
=
0
for
c
in
formula
:
if
c
in
charset
:
if
state
==
1
:
output
=
output
+
"
𝟙
"
+
c
state
=
0
else
:
output
=
output
+
c
else
:
if
state
==
"
after first character
"
:
if
char
==
"
𝟙
"
:
break
else
:
output
+=
char
if
state
==
1
:
continue
else
:
#reach formula
for
j
in
range
(
i
,
-
1
,
-
1
):
if
formula
[
j
]
==
"
"
:
break
else
:
output
=
formula
[
j
]
+
output
state
=
"
after first character
"
print
(
"
find formula
"
,
output
)
return
(
output
.
strip
(),
idx
)
state
=
1
return
output
def
updateBaseFormula
(
tname
,
count
,
base
):
charset
=
[
"
⊕
"
,
"
⊗
"
,
"
⊖
"
,
"
"
,
"
(
"
,
"
)
"
]
output
=
""
tmp
=
0
state
=
0
for
i
,
c
in
enumerate
(
base
):
if
c
in
charset
:
if
state
==
1
:
tmp
+=
1
state
=
0
output
+=
c
continue
elif
c
==
"
𝟙
"
:
if
tmp
==
count
:
output
=
output
+
tname
output
=
output
+
base
[
i
+
1
:]
break
else
:
output
+=
c
tmp
+=
1
else
:
if
state
==
0
:
state
=
1
output
+=
c
return
output
def
remove1sAndAddTablename
(
formula
,
table
):
nf
,
idx
=
findFormula
(
formula
)
elements
=
nf
.
split
(
"
"
)
for
i
,
e
in
enumerate
(
elements
):
if
e
in
[
"
⊕
"
,
"
⊗
"
,
"
⊖
"
]:
continue
def
remove1sAndAddTablename
(
formula
,
table
,
base
):
charset
=
[
"
⊕
"
,
"
⊗
"
,
"
⊖
"
,
"
"
,
"
(
"
,
"
)
"
]
count
=
0
state
=
0
tname
=
""
for
c
in
formula
:
if
c
in
charset
:
if
state
==
1
:
state
=
0
base
=
updateBaseFormula
(
table
+
"
.
"
+
tname
,
count
,
base
)
tname
=
""
count
+=
1
continue
elif
c
==
"
𝟙
"
:
count
+=
1
else
:
if
"
(
"
in
e
:
eidx
=
e
.
index
(
"
(
"
)
+
1
ne
=
e
[:
eidx
]
+
table
+
"
.
"
+
e
[
eidx
:]
elements
[
i
]
=
ne
else
:
ne
=
table
+
"
.
"
+
e
elements
[
i
]
=
ne
output
=
"
"
.
join
(
elements
)
return
(
output
.
strip
(),
idx
)
if
state
==
0
:
state
=
1
tname
=
tname
+
c
return
base
def
compareTwoRows
(
row1
,
row2
):
for
i
in
range
(
1
,
len
(
row1
)
-
1
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment