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

missing path as token #48

Open
NSP-0123456 opened this issue May 6, 2023 · 5 comments
Open

missing path as token #48

NSP-0123456 opened this issue May 6, 2023 · 5 comments

Comments

@NSP-0123456
Copy link

Hi could you implementa path toen in order to get it in the output format or in the where clause ?

@kashav
Copy link
Owner

kashav commented May 6, 2023

Hi, I don’t really understand what you’re asking. Can you provide an example of what you’re running and what you wish to be doing with this feature request?

@kashav
Copy link
Owner

kashav commented May 6, 2023

I don’t write much Go anymore, so I might not get around to this any time soon. I’d be happy to review/merge a PR if you wanted to submit one.

@kashav
Copy link
Owner

kashav commented May 6, 2023

You can get the FULLPATH/SHORTPATH in the output, but can't use it in the WHERE clause yet. We'll throw a not-implemented-error here:

fsql/transform/parse.go

Lines 59 to 75 in 7e90fdf

switch strings.ToUpper(p.Name) {
case "FORMAT":
val, err = p.format()
case "UPPER":
val = upper(p.Value.(string))
case "LOWER":
val = lower(p.Value.(string))
case "SHA1":
val, err = p.hash(FindHash(p.Name)())
}
if err != nil {
return nil, err
}
if val == nil {
return nil, &ErrNotImplemented{p.Name, p.Attribute}
}

Making it work in WHERE clauses requires applying the Modifier function to the filename when doing the comparison here:

// evaluateName evaluates a Condition with attribute `name`.
func evaluateName(o *Opts) (bool, error) {
var a, b interface{}
switch o.Value.(type) {
case string, []string, map[interface{}]bool:
a = o.File.Name()
b = o.Value
default:
return false, &ErrUnsupportedType{o.Attribute, o.Value}
}
return cmpAlpha(o, a, b)
}

which can also happen when doing the actual comparison:

fsql/evaluate/compare.go

Lines 13 to 15 in 7e90fdf

// cmpAlpha performs alphabetic comparison on a and b.
func cmpAlpha(o *Opts, a, b interface{}) (result bool, err error) {
switch o.Operator {

I might take a look at this at some point but let me know if you decide to.

@NSP-0123456
Copy link
Author

NSP-0123456 commented May 11, 2023

even if i use FULLPAH(name) in select i only get relative path + file name when using . in from.
SHORTPATH(name) only return name in all conditons.
PATH is normally the location of the file and should no contain file name. FULLNAME is more appropriate as format function.

@kashav
Copy link
Owner

kashav commented May 15, 2023

Let me think about this more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants