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

SNOW-1433638: Symbol -- cannot be treated as a string. #949

Closed
e8-ZhixinYang opened this issue May 17, 2024 · 6 comments
Closed

SNOW-1433638: Symbol -- cannot be treated as a string. #949

e8-ZhixinYang opened this issue May 17, 2024 · 6 comments
Assignees
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@e8-ZhixinYang
Copy link

e8-ZhixinYang commented May 17, 2024

Symbol -- cannot be treated as a string.

  1. What version of .NET driver are you using?
    3.1.0

  2. What version of .NET framework are you using?
    .net 8.0

1)SELECT '--'; can work properly and return the result "--".

2)`
SELECT '--'

;
` encountered the following error.

SQL compilation error: parse error line 1 at position 9 near ''. syntax error line 1 at position 8 unexpected ';'.

When I was using version 2.1.0, both 1) and 2) could work properly. Do we need to make any changes?
I have checked the source code of version 3.1.0:

        private string TrimSql(string originalSql)
        {
            char[] sqlQueryBuf = originalSql.ToCharArray();
            var builder = new StringBuilder();

            // skip old c-style comment
            var idx = 0;
            var sqlQueryLen = sqlQueryBuf.Length;
            do
            {
                if (('/' == sqlQueryBuf[idx]) &&
                    (idx + 1 < sqlQueryLen) &&
                    ('*' == sqlQueryBuf[idx + 1]))
                {
                    // Search for the matching */
                    var matchingPos = originalSql.IndexOf("*/", idx + 2);
                    if (matchingPos >= 0)
                    {
                        // Found the comment closing, skip to after
                        idx = matchingPos + 2;
                    }
                }
                else if ((sqlQueryBuf[idx] == '-') &&
                         (idx + 1 < sqlQueryLen) &&
                         (sqlQueryBuf[idx + 1] == '-'))
                {
                    // Search for the new line
                    var newlinePos = originalSql.IndexOf("\n", idx + 2);

                    if (newlinePos >= 0)
                    {
                        // Found the new line, skip to after
                        idx = newlinePos + 1;
                    }
                }

                // No more characters after the closing comment character, stop trimming the query
                if (idx >= sqlQueryLen)
                {
                    break;
                }

                builder.Append(sqlQueryBuf[idx]);
                idx++;
            }
            while (idx < sqlQueryLen);

            var trimmedQuery = builder.ToString();
            trimmedQuery = trimmedQuery.Trim();
            logger.Debug("Trimmed query : " + trimmedQuery);

            return trimmedQuery;
        }

@github-actions github-actions bot changed the title Symbol -- cannot be treated as a string. SNOW-1433638: Symbol -- cannot be treated as a string. May 17, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this May 22, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label May 22, 2024
@sfc-gh-dszmolka
Copy link
Contributor

thank you for reporting this error - checking it

@sfc-gh-dszmolka
Copy link
Contributor

i'm not sure about the TrimSql part because it was last touched in 2.0.20, but this is definitely a confirmed bug. Last working version is 2.2.0, and the next one (3.0.0) does not work anymore and throws the error you mentioned.

We'll take a look and fix it. I'll keep this thread updated with the progress.

@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage_done Initial triage done, will be further handled by the driver team status-pr_pending_merge A PR is made and is under review and removed status-triage Issue is under initial triage labels May 23, 2024
@sfc-gh-dszmolka
Copy link
Contributor

PR under review with the fix #957

@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-pr_pending_merge A PR is made and is under review labels Jun 7, 2024
@sfc-gh-dszmolka
Copy link
Contributor

Thank you for your patience here while we were undergoing a momentary code freeze period due to Summit.
Now the change is merged, and will be part of the 2024 June release, probably towards the end of month.

@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Jun 24, 2024

Will update this thread once more information is known about the next upcoming major release of the .NET driver which will carry this fix.

edit: confirming with Product team; release should be available by mid-July 2024

@sfc-gh-dszmolka
Copy link
Contributor

fix released with Snowflake .NET driver version v4.0.0 in July 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants