Skip to content
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

[CIVP-24324] FIX remove _get_headers in read_civis_sql #415

Merged
merged 7 commits into from
Nov 24, 2021

Conversation

madopal
Copy link

@madopal madopal commented Feb 9, 2021

This PR removes the helper function _get_headers used by civis.io.read_civis_sql.

Originally, @madopal discovered a bug in this helper function. John Kulzick then commented that this helper function should in fact be removed based on the current state of the internal Civis Platform code.

For reference, the following is @madopal 's original PR description:


  • As it stands now, if an error is tripped in _get_headers, it silently fails. However, a simple fail can be invoked if the sql being checked is terminated with a semicolon. So a strip of the semicolon is added to cover a few more cases & get the
    optimization of that routine. Because the entire failure is labeled NOQA, tests aren't really possible. However, it was run with some queries to verify it doesn't blow up.

- As it stands now, if an error is tripped in _get_headers,
it silently fails. However, a simple fail can be invoked if the
sql being checked is terminated with a semicolon. So a strip of
the semicolon is added to cover a few more cases & get the
optimization of that routine. Because the entire failure is labeled
NOQA, tests aren't really possible. However, it was run with some
queries to verify it doesn't blow up.
@salilgupta1
Copy link
Contributor

Sorry, I'm a bit confused. You want to remove semi-colons because it will throw the error or you want to remove the semi-colon because it will further suppress the error?

@madopal
Copy link
Author

madopal commented Feb 10, 2021

So, it seems like the benefit of looking up the header can be done regardless of whether or not the query is terminated by a semicolon, no?
If so, then we need to either 1) strip the semicolon when we get it and try to get the header or 2) document that if any SQL query is semicolon terminated, it will silently fail & skip the optimization. I had assumed the former, as if it fails it's no worse than how it is now, but if we have a reason for not gaining the benefit of the header when the query is semicolon-terminated, then it should at least be mentioned in the higher level call, right?

@salilgupta1
Copy link
Contributor

ok, I get what you are saying. I have no opinion since i'm not familiar with this code. @mheilman do you have any thoughts?

@jkulzick
Copy link
Contributor

jkulzick commented Feb 10, 2021

The _get_headers code should just be removed. It was added at a time when SQL Scripts did not support doing a parallel unload if headers were requested. At that time, rather than fixing it on the API side, it was easier to add this code on the client side. The API side has since been addressed making the _get_headers code redundant. The bug this PR addresses has already been addressed in the API side code.

I'm happy to provide context to things in the Python API client like this, but we do need to expand the bus factor and get other people involved in CR.

@madopal
Copy link
Author

madopal commented Feb 11, 2021

Happy to just close this if that's the solution @jkulzick, unless you'd rather I modify it to remove _get_headers?

@jkulzick
Copy link
Contributor

Happy to just close this if that's the solution @jkulzick, unless you'd rather I modify it to remove _get_headers?

@madopal yeah, we should modify this to remove _get_headers

@jacksonlee-civis jacksonlee-civis changed the title BUG: Add strip of semicolon to _get_headers [CIVP-24324] REF Drop _get_headers in read_civis_sql Nov 3, 2021
@jacksonlee-civis jacksonlee-civis removed the request for review from salilgupta1 November 4, 2021 02:01
@jacksonlee-civis jacksonlee-civis changed the title [CIVP-24324] REF Drop _get_headers in read_civis_sql [CIVP-24324] FIX remove _get_headers in read_civis_sql Nov 24, 2021
@pytest.mark.read_civis
@pytest.mark.skipif(not has_pandas, reason="pandas not installed")
@mock.patch(api_import_str, return_value=civis_api_spec)
def test_read_civis_pandas(self, *mocks):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These cassette-based tests wouldn't pass. Since we've been gradually removing/replacing these cassette tests with mock-based ones anyway (e.g, #328, #425), I'm doing the same here with the read_civis(_sql) tests. (read_civis is a thin wrapper of read_civis_sql, and so below I'm explicitly testing read_civis_sql only.)

@jacksonlee-civis
Copy link
Member

@skomanduri Tagging you for review here, as we'd need someone with knowledge of the Platform code. In particular, is Kulzick's comment still accurate at this point given the current state of Platform? Thank you.

@jacksonlee-civis jacksonlee-civis changed the title [CIVP-24324] FIX remove _get_headers in read_civis_sql [CIVP-24324] FIX remove _get_headers in read_civis_sql Nov 24, 2021
@skomanduri
Copy link
Contributor

@jacksonlee-civis Yep, the comment is still accurate! This logic has been moved into Platform so it can be removed from the client.

Copy link
Contributor

@skomanduri skomanduri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jacksonlee-civis jacksonlee-civis merged commit ef50b5f into master Nov 24, 2021
@jacksonlee-civis jacksonlee-civis deleted the fix/strip_semicolon_from_get_headers_sql branch November 24, 2021 20:34
@jacksonlee-civis jacksonlee-civis added this to the v1.16.0 milestone Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants