When I query a view using a varchar in my clause, it doesn't return anything unless I use an int. Is there something wrong with my code or is it Synapse?

Kane Newton-Stallwood 0 Reputation points
2023-03-15T11:18:52.0166667+00:00

Hello everyone,

I am completely stumped with my issue. I am trying to query a view I made with two fields called year and month. They are both NVARCHAR's but when I query the view using month = '01' AND year = '2020' I get no results.

User's image

However, when I query the view this way ... I get results

User's image

This is how I created my view:

GO

DROP VIEW IF EXISTS silver.vw_trip_data_green

GO


CREATE view silver.vw_trip_data_green
AS
SELECT 
    result.filepath(1) AS year,
    result.filepath(2) AS month,
    result.*
FROM 
    OPENROWSET(
        BULK 'silver/trip_data_green/year=*/month=*/*.parquet',
        DATA_SOURCE = 'nyc_taxi_src',
        FORMAT = 'PARQUET'
    ) WITH (
        vendor_id INT,
        lpep_pickup_datetime DATETIME2(7),
        lpep_dropoff_datetime DATETIME2(7),
        store_and_fwd_flag CHAR(1),
        ratecode_id INT,
        pu_location_id INT,
        do_location_id INT,
        passenger_count INT,
        trip_distance FLOAT,
        fare_amount FLOAT,
        extra FLOAT,
        mta_tax FLOAT,
        tip_amount FLOAT,
        tolls_amount FLOAT,
        ehail_fee FLOAT,
        improvement_surcharge FLOAT,
        total_amount FLOAT,
        payment_type INT,
        trip_type INT,
        congestion_surcharge FLOAT
    )    AS [result]

Is there something fundamental I'm missing or is there an issue with Synapse?

Kind regards,

Kane.

Azure SQL Database
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,378 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kane Newton-Stallwood 0 Reputation points
    2023-03-15T11:51:40.0933333+00:00

    Don't worry, I found the issue. It was a bloody space in my code. Have a good day


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.