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

Convert unicode to bytestring in formatCursor #9204

Closed
wants to merge 1 commit into from

Conversation

amaltaro
Copy link
Contributor

Fixes dmwm/DBS#605
Well, another proposal to fix it. This fix goes as close as possible to the SQL/database layer.

I have a couple of concerns though:

  • it will apply to every single result calling DBFormatter.formatCursor. So there is some overhead here (complexity O(n^3)!)
  • if data is not formatted with one of those methods handling unicode, then there is the risk to pass unicode string data to the next SQL query.

PS.: Oracle returns table/column names in capital, should we apply .lower()? I guess not, there wasn't anything in the previous implementation.

@bbockelm
Copy link
Contributor

This breaks the ability to stream results in the future, no?

@vkuznet
Copy link
Contributor

vkuznet commented May 17, 2019

Alan, I would vote to NOT do it. This code has plenty of issues by itself (e.g. it should not construct objects and put them in a list, instead it should yield results for streaming) and adding additional complexity may have dramatic consequences everywhere (e.g. DBS, T0, etc.)

@amaltaro
Copy link
Contributor Author

@bbockelm I don't think so. Looking at how it's used in DBS, it expands some rows and return it as a generator:
https://github.com/dmwm/DBS/blob/master/Server/Python/src/dbs/dao/Oracle/Block/List.py#L144

@vkuznet see reply above. In addition to that, this fix does NOT change anything but casting unicode to string. ALL the rest keeps exactly the same logic/behavior as before.

@amaltaro
Copy link
Contributor Author

Even the additional complexity... it's just more visible now; it was there before, just hidden by the zip function.

@vkuznet
Copy link
Contributor

vkuznet commented May 17, 2019 via email

@bbockelm
Copy link
Contributor

Gross. The whole API is a flurry of object churn, switching between lists and generators.

Honestly - is it better to just either scrap this (introducing a formatCursorV2 that is all generator-based) or force the caller to declare what behavior they need instead of doing it under the hood?

@amaltaro
Copy link
Contributor Author

Given that we're talking about a hot fix for DBS, I'd add the minimum amount of changes in, the safest the best. Then for the upcoming June release, we try to get an improved version of it.

Yes Valentin, I can do that. I switched gears for the moment and will get back to it later. If @yuyiguo can benchmark it, it's even better.

@vkuznet
Copy link
Contributor

vkuznet commented May 17, 2019

@bbockelm , Brian I proposed full redesign of this and other modules in 2015, see #6337 (and before that here #6284) The changes I made based on pure python based iterators instead of using SQLAlchemy. The code was discussed, tested, merged and put under the rug and never get into the main tree.

@amaltaro , Alan I understand desire to do hot-fix but as history shows the proper solution may not appear and be implemented or put in place.

@bbockelm
Copy link
Contributor

@vkuznet - indeed, it's worthwhile - and important - to go back to this item. However, I am reluctant to do this until the dust has settled.

@amaltaro
Copy link
Contributor Author

PR probably no longer needed. We shall work on this issue instead:
#9207

and a possible rework between WMCore/DBS for proper use of generators.

@amaltaro
Copy link
Contributor Author

This was a possible hot fix for DBS and seems to be no longer relevant. Please let me know otherwise such that I can reopen it.

@amaltaro amaltaro closed this Jul 19, 2019
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.

MIgration failures
3 participants