-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snowflake import backend #584
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
mitosheet/src/components/taskpanes/SplitTextToColumns/SplitTextToColumnsTaskpane.tsx
Outdated
Show resolved
Hide resolved
Note: For the purposes of this PR I set up a testing Snowflake instance, it has only the default getting started data in it. I will delete that instance after this PR and we can set up a new instance for anything else we want to do because I accidentally committed my credentials. |
db806d0
to
320dbde
Compare
WE NEED TO REMOVE [ActionEnum.SNOWFLAKEIMPORT]: before merging. Will do as last step after you review |
mitosheet/mitosheet/step_performers/import_steps/snowflake_import.py
Outdated
Show resolved
Hide resolved
Two callouts for you to pay special attention to:
|
I think it should interact with our type system mostly fine! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more things to cleanup, I'll hop on em
table_loc_and_warehouse: SnowflakeTableLocationAndWarehouse = get_param(params, 'table_loc_and_warehouse') | ||
connection_params_dict = get_connection_param_dict(get_param(params, 'credentials'), table_loc_and_warehouse) | ||
|
||
query_params: SnowflakeQueryParams = get_param(params, 'query_params') | ||
table = table_loc_and_warehouse['table'] | ||
sql_query = create_query(table, query_params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one final refactor here. You should:
- Return these variables (namely,
connection_params_dict
andsql_query
) in execution data above. - Get it form the execution data in this function.
This means you have to redo zero work -- which again reduces the chances we'll make silly bugs and forget to change things.
username = credentials['username'] | ||
password = credentials['password'] | ||
account = credentials['account'] | ||
warehouse = table_loc_and_warehouse['warehouse'] | ||
database = table_loc_and_warehouse['database'] | ||
schema = table_loc_and_warehouse['schema'] | ||
|
||
all_params: Dict[str, str] = {} | ||
all_params['user'] = username | ||
all_params['password'] = password | ||
all_params['account'] = account | ||
all_params['warehouse'] = warehouse | ||
all_params['database'] = database | ||
all_params['schema'] = schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be cut in half.
|
||
# Remove the test file | ||
os.remove(TEST_FILE_PATHS[0]) | ||
os.remove(TEST_FILE_PATHS[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add an optimization test as well!
const [availableSnowflakeOptionsAndDefaults, setAvailableSnowflakeOptionsAndDefaults] = useState<AvailableSnowflakeOptionsAndDefaults | undefined>(undefined); | ||
const [refreshDefaultsNumber, setRefreshDefaultsNumber] = useState(0) | ||
|
||
const refreshAvailableOptionsAndDefaults = (newParams: SnowflakeImportParams): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, I think, should just a setParams call. And we should change the names of setParams above. Will cleanup this code a bit.
return await props.mitoAPI.validateSnowflakeCredentials(params.credentials) | ||
} | ||
|
||
const getNewParams = (database?: string | null, schema?: string | null, table?: string | null) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need not be defined inline
setParams((prevParams) => { | ||
return { | ||
...prevParams, | ||
credentials: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, we should use the partial updater function. I'll update this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, I found a bug in the setting of the new warehouse while updating to this -- a wrong key was being used. The partial updater function is actually more type safe than standard react!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also -- just a reminder that const paramsCopy: SnowflakeImportParams = {...params}
is not an actual copy, if you have nested objects (which we certainly do here).
I'm doing some refactoring of the frontend code. I'd love to talk through it at some point. There's a bunch of opportunity for learning, I think, namely around how to -factor- functions. What should be included and what shoudn't. E.g. setCredentialsSectionIsOpen function should be called within the validateSnowflakeCredentials section, etc. |
ee2994e
to
fd4baca
Compare
fd4baca
to
3b05f5f
Compare
@aarondr77 ok, a few things to call out:
In practice, I was able to remove the effect triggered by the update number entirely - and move to just making a function call. This makes things much simpler, and easier to follow - and better function names help a lot as well. Let me know if you want to chat about it at all. If this looks good, let's a) remove the action, and b) merge this guy! |
Description
validate_snowflake_credentials
andget_available_snowflake_options_and_defaults
api calls. Adds thesnowflake_import
step performer.Testing
This is supposed to just be a backend PR, so see tests.
Last week I invited you to join our testing snowflake environment. You should be able to add those credentials to a .env file and then use those credentials for testing. Otherwise, give me a call and I can give you the Pytest credentials.
Documentation
Not yet.