-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add Enum and JSONString type #30
base: main
Are you sure you want to change the base?
Conversation
@wey-gu Lets put this a bit on hold. So the first issue I encounter is that Enum and JSON arent represented as types in Nebula, for obvious reasons. For this approach to work, we would need to have carina being able to "enable" more comples types with validation, but underneath translating them to primitive types handled by nebula-python. I am thinking abit how to actually do that in a clean way. But the PR as it stands right now, does not. I do still think it would be benefitical to "support" other types for easier and more seemless validation with pydantic, but it has to be done in a clean and readable way. Im gonna think a bit and revise thise PR. Put it on hold for now, and Ill ping you again. |
Sorry was super busy these days. My idea on implementing enum in NebulaGraph would be:
What do you think, please? Regarding JSON:
What do you think? @magnudae sorry again to let you down on being so late responses. |
@wey-gu No worries. For the enum, that sounds similar to what ive been thinking of. For the JSON structure, im currently trying out in my fork a way to extend the current String DataType, to handle JSON. Suggestion 1 might be the easiest to do, but with a depth of 2 that would be quite limiting. I think we could expect the user of carina to extract the JSON as long as carina returns the string. Suggestion 2, I think I understand the concept, but wouldnt that be a bit complex since we would need EdgeTypes for each field? Or would we introduce some kind of "JSON" EdgeType for this. Depth would also be a problem here, since it sounds complex to calculate depth on these edges from a JSON string, unless that comes predefined by the user (maybe?) Anyway, our use case is currently that we have JSON configs that trigger different actions, depending on the context of the user. I will work a bit further and hopefully drop a PR here with some suggestions. Also, sorry for pinging you so much, just been quite exciting to explore Nebula |
Thanks and looking forward to your exploration :) To enable notifications on not missing this, I'll reopen this pr first(don't know how to transfer a PR to an issue or discussion thread) |
Im not familiar enough with C++, so I dont think I will propose anything for Nebula yet I am working with slight change of the Will probably take me some more time than before to get a proper PR ready, since I have it similar to you, a lot on my plate right now. |
Yeah sure, the first version to be purely orm side should already meet your needs, we could then make the extraction server-side when some real perf issue encountered(not likely I guess, either). Looking forward to your work🫡 and take your time, please. |
We were working with some new nodes that were using Enums and JSONStrings and encountered some issues
With Enums we would always have to call the
.value
everywhere since there were no Enum interpreter in Nebula.Since Enums are basically strings I thought we could use a type that would just save the value.
I also wanted to be able to interpret it on the way up from the DB, but that might be something needed in the main nebula package?
For JSON strings, the syntax of JSON dictates it uses double quotes. If we just use the String type in carina we get error because it just wraps the whole thing in double quotes and it becomes an invalid object. Solution was to for this type switch to wrapping in single quotes.
Both cases we could handle by making our own wrappers around, but I thought this might be valuable to have within Carina, to help the users along.
@wey-gu Please guide me here. Is this out of scope? Do you guys have something to deal with this already?
Or is there something I havent thought of here?