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-1522886: row_number() Function Fails on Empty DataFrame with "No Objects to Concatenate" Error #1882

Closed
hima-gopisetty opened this issue Jul 5, 2024 · 4 comments
Assignees
Labels
bug Something isn't working local testing Local Testing issues/PRs status-triage_done Initial triage done, will be further handled by the driver team

Comments

@hima-gopisetty
Copy link

Please answer these questions before submitting your issue. Thanks!

1. What version of Python are you using?

   Python 3.11.8 

2. What are the Snowpark Python and pandas versions in the environment?

  pandas==1.5.3
  snowflake-snowpark-python==1.14.0
  1. What did you do?

    from snowflake.snowpark.functions import col, row_number
    from snowflake.snowpark.window import Window
    from snowflake.snowpark.types import StringType, StructField, StructType, TimestampType
    from snowflake.snowpark import Session
    
    # Create a Snowflake session
    session = Session.builder.configs({"local_testing": True}).create()
    
    # Define the schema for the DataFrame
    schema = StructType([
        StructField("ROLE_NAME", StringType()),
        StructField("GIT_COMMIT_VALUE", StringType()),
        StructField("RECORD_CREATED_TS", TimestampType())
    ])
    
    # Create an empty DataFrame with the defined schema
    sf_df = session.create_dataframe([], schema)
    
    
    # Define the window specification
    window = Window.partitionBy("ROLE_NAME").orderBy(col("RECORD_CREATED_TS").desc())
    
    # Apply the row_number() function using the window specification
    sf_ts = sf_df.with_column("RN", row_number().over(window))
    
    # Show the resulting DataFrame
    sf_ts.show() # issueValueError: No objects to concatenate when using the row_number() function on empty dataframe
  2. What did you expect to see?

    I expected to see an empty DataFrame with an additional "RN" column when running. Instead, I encountered the following issue:

    ValueError: No objects to concatenate
    

    The code should handle empty DataFrames gracefully and return an empty DataFrame with the "RN" column added.

Additional Note:

It's important to mention that the operations described above work as expected when executed in a standard Snowflake session. The issues outlined occur exclusively during local testing with the Snowpark library.
@hima-gopisetty hima-gopisetty added bug Something isn't working local testing Local Testing issues/PRs needs triage Initial RCA is required labels Jul 5, 2024
@github-actions github-actions bot changed the title row_number() Function Fails on Empty DataFrame with "No Objects to Concatenate" Error SNOW-1522886: row_number() Function Fails on Empty DataFrame with "No Objects to Concatenate" Error Jul 5, 2024
@trakmaker
Copy link

@hima-gopisetty I believe you are running commands directly in the terminal, that's when I got the error same as yours but please correct me if I am wrong. Executing the same inside the python environment works fine for me.

PS: I am using very similar configuration as your environment setup

@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Jul 8, 2024
@sfc-gh-sghosh
Copy link

Hello @hima-gopisetty ,

Thanks for raising the issue.
We are able to reproduce the issue with local_testing and will work on eliminating it.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team and removed needs triage Initial RCA is required labels Jul 8, 2024
@sfc-gh-aling
Copy link
Contributor

hey @hima-gopisetty , I believe the issue has been fixed already in the latest release of snowpark python. I ran your code against snowpark 1.20.0 and it works well.

could you try upgrade and see if the issue is gone?

@sfc-gh-aling
Copy link
Contributor

I'm closing the issue since there is no response. please free feel to reach out if the issue is still observed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working local testing Local Testing issues/PRs status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

5 participants