Create New Dialect for SAS PROC SQL #2192
-
| 
         Hello! Thank you for creating such a wonderful library...it really is a pleasure to use. I understand my use case my be completely outside the scope of what this library is aiming for, but I am trying to parse out SAS PROC SQL. My goal is to parse out the metadata and not to transpile to another SQL dialect. So far, I have done a bit of pre-processing to PROC SQL text to try and strip it of any SAS-specific syntax. However, I am starting to realize it may be more efficient/sane to extend the  If anyone is willing, I was hoping for some guidance in how I could parse out something like the following: SELECT
    COALESCE(fieldA, fieldB) AS aliasAB,
    PUT(fieldC, best.) AS aliasC,
    PUT(INPUT(CALCULATED aliasAB, best20.), z20.) AS aliasE
from tblThe   | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| 
         Functions of the form  Functions like  You can also reach out in slack if you wanna chat about your use case in more depth.  | 
  
Beta Was this translation helpful? Give feedback.
Functions of the form
name(arg1, ..., argn)are automatically handled by SQLGlot and they're either parsed into a "known"Funcexpression (i.e. AST node), for exampleexp.Avg, or intoexp.Anonymouswhich is a "fallback" type for unknown functions.Functions like
PUTshould thus be already handled for you (with the exception ofbest., which I'm not sure what it means and it's probably not handled at the moment). For functions likeINPUTthat have "special syntax", i.e. theCALCULATEDpart, you'll need to add an entry toFUNCTION_PARSERSto specify the specialized parsing logic. There are plenty of examples in the codebase, so you can use them as a guide.You can also reach out in slack if …