where clause won't work in sql transform in glue

0

where clause doesn't work in sql transform in glue. any help is appreciated.

질문됨 일 년 전515회 조회
1개 답변
0

We would need more details on what is the issue that you are exactly facing , but check if the below helps you .

In the glue script below note the abc text . The query by itself just uses that literal , whereas in the later section , abc is actually being mapped to the sql table . sparkSqlQuery is a custom function that is written to execute the sql

You can simulate a similar script if you devise just this section of the code in a new visual job.

def sparkSqlQuery(glueContext, query, mapping, transformation_ctx) -> DynamicFrame:
    for alias, frame in mapping.items():
        frame.toDF().createOrReplaceTempView(alias)
    result = spark.sql(query)
    return DynamicFrame.fromDF(result, glueContext, transformation_ctx)



# Script generated for node SQL
SqlQuery0 = """
select 
year(create_time)          as create_time_year,
month(create_time)         as create_time_month,
count(id)                  as count_of_records 
from abc
where 
create_time is not null 
group by year(create_time),month(create_time)
order by year(create_time),month(create_time)

"""
SQL_node = sparkSqlQuery(
    glueContext,
    query              =SqlQuery0,
    mapping            ={"abc": sql_node},
    transformation_ctx ="SQL_node",
)
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠