Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
HOTMapper
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
HOTMapper
HOTMapper
Commits
524a87a5
Commit
524a87a5
authored
4 years ago
by
jvfpw18
Browse files
Options
Downloads
Patches
Plain Diff
Fix derivatives not being executed
parent
58d9986a
No related branches found
No related tags found
1 merge request
!15
Two way derivatives, fix constants being inserted after derivatives
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
database/database_table.py
+22
-11
22 additions, 11 deletions
database/database_table.py
with
22 additions
and
11 deletions
database/database_table.py
+
22
−
11
View file @
524a87a5
...
@@ -203,6 +203,8 @@ class DatabaseTable(Table):
...
@@ -203,6 +203,8 @@ class DatabaseTable(Table):
bind
=
self
.
metadata
.
bind
bind
=
self
.
metadata
.
bind
pks
=
get_primary_keys
(
self
)
pks
=
get_primary_keys
(
self
)
if
len
(
pks
)
>
0
:
primary_keys
=
(
ttable
.
columns
.
get
(
pk
.
name
)
for
pk
in
pks
)
primary_keys
=
(
ttable
.
columns
.
get
(
pk
.
name
)
for
pk
in
pks
)
new_pk
=
PrimaryKeyConstraint
(
*
primary_keys
)
new_pk
=
PrimaryKeyConstraint
(
*
primary_keys
)
...
@@ -790,7 +792,7 @@ class DatabaseTable(Table):
...
@@ -790,7 +792,7 @@ class DatabaseTable(Table):
if
target
is
not
None
and
str
(
self
)
+
'
.
'
+
target
in
recursion_list
:
if
target
is
not
None
and
str
(
self
)
+
'
.
'
+
target
in
recursion_list
:
# This is a circular reference. Don't be like that.
# This is a circular reference. Don't be like that.
print
(
target
)
print
(
target
,
self
)
raise
CircularReferenceError
(
target
)
raise
CircularReferenceError
(
target
)
# Query for the column, header of csv or var name if empty
# Query for the column, header of csv or var name if empty
...
@@ -815,7 +817,10 @@ class DatabaseTable(Table):
...
@@ -815,7 +817,10 @@ class DatabaseTable(Table):
referred_tables
=
[]
referred_tables
=
[]
case
=
case
.
strip
(
"
~
"
)
# doesn't need "~" anymore
case
=
case
.
strip
(
"
~
"
)
# doesn't need "~" anymore
for
substr
in
case
.
split
():
str_list
=
re
.
findall
(
r
'
(
"
[\w]
"
|[\w.]+)
'
,
case
)
# str_list = case.split()
for
substr
in
str_list
:
# print('ss', substr)
if
'
.
'
in
substr
:
# We have a var from another table
if
'
.
'
in
substr
:
# We have a var from another table
table
=
substr
.
split
(
'
.
'
)[
0
]
table
=
substr
.
split
(
'
.
'
)[
0
]
table
=
gen_data_table
(
table
,
self
.
metadata
)
table
=
gen_data_table
(
table
,
self
.
metadata
)
...
@@ -825,10 +830,15 @@ class DatabaseTable(Table):
...
@@ -825,10 +830,15 @@ class DatabaseTable(Table):
var_name
=
substr
var_name
=
substr
# If it is a var, will need to be evaluated as it's a dependency.
# If it is a var, will need to be evaluated as it's a dependency.
if
table
.
_protocol
.
target_from_dbcolumn
(
var_name
)
is
not
None
:
if
table
.
_protocol
and
table
.
_protocol
.
target_from_dbcolumn
(
var_name
)
is
not
None
:
# Prevents lowering level if var is an aggregation.
# Prevents lowering level if var is an aggregation.
print
(
"
VAR
"
,
var_name
)
level
=
max
(
level
+
table
.
_derivative_recursion
(
var_name
,
year
,
recursion_list
)[
'
level
'
],
level
)
level
=
max
(
level
+
table
.
_derivative_recursion
(
var_name
,
year
,
recursion_list
)[
'
level
'
],
level
)
else
:
var_target
=
self
.
_get_variable_target
(
var_name
.
strip
(
'"'
),
year
)
if
var_target
is
not
None
:
var_db
=
self
.
_protocol
.
dbcolumn_from_target
(
var_target
)[
0
]
case
=
case
.
replace
(
var_name
,
var_db
)
if
table
is
not
self
and
table
not
in
referred_tables
:
if
table
is
not
self
and
table
not
in
referred_tables
:
referred_tables
.
append
(
table
)
referred_tables
.
append
(
table
)
...
@@ -880,11 +890,12 @@ class DatabaseTable(Table):
...
@@ -880,11 +890,12 @@ class DatabaseTable(Table):
def
_apply_denormalization
(
self
,
ttable
,
year
,
column
,
denorm_query
,
referred_tables
,
bind
):
def
_apply_denormalization
(
self
,
ttable
,
year
,
column
,
denorm_query
,
referred_tables
,
bind
):
query
=
update
(
ttable
)
query
=
update
(
ttable
)
print
(
ttable
.
name
)
query
=
query
.
values
(
**
{
column
:
text
(
denorm_query
)})
query
=
query
.
values
(
**
{
column
:
text
(
denorm_query
)})
print
(
'
qc
'
,
query
,
column
)
for
ref_table
in
referred_tables
:
for
ref_table
in
referred_tables
:
ref_table
=
gen_data_table
(
ref_table
,
self
.
metadata
)
ref_table
.
map_from_database
(
bind
)
ref_table
.
map_from_database
(
bind
)
try
:
try
:
fk_tuples
=
[(
ttable
.
columns
.
get
(
fk_column
.
name
),
fkey
)
fk_tuples
=
[(
ttable
.
columns
.
get
(
fk_column
.
name
),
fkey
)
...
...
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