WITH SPECIAL_HANDLING_AIRLINE as (select regexp_substr(str, '[^,]+', 1, LEVEL) from (select AP.PARAMETER_VALUE str from FM_APPLICATION_PARAMETERS AP WHERE PARAMETER_CODE='TONNAGE_SPECIAL_HANDLING_AIRLINE') CONNECT BY LEVEL <= regexp_count(str, ',') + 1), SPECIAL_REVENUE_TYPE as (select regexp_substr(str, '[^,]+', 1, LEVEL) from (select AP.PARAMETER_VALUE str from FM_APPLICATION_PARAMETERS AP WHERE PARAMETER_CODE='TONNAGE_SPECIAL_REVENUE_TYPE') CONNECT BY LEVEL <= regexp_count(str, ',') + 1), SPECIAL_SHIPMENT_FLOW_TYPE as (select regexp_substr(str, '[^,]+', 1, LEVEL) from (select AP.PARAMETER_VALUE str from FM_APPLICATION_PARAMETERS AP WHERE PARAMETER_CODE='TONNAGE_SPECIAL_SHIPMENT_FLOW_TYPE') CONNECT BY LEVEL <= regexp_count(str, ',') + 1), SPECIAL_HANDLING_EFF_DATE as ( SELECT TO_DATE(PARAMETER_VALUE, 'YYYYMMDD') EFF_DATE from FM_APPLICATION_PARAMETERS where PARAMETER_CODE='TONNAGE_SPECIAL_HANDLING_EFFECTIVE_DATE' ) select * from SPECIAL_HANDLING_AIRLINE;以上是oracle的写法,请转换成spark SQL的写法。
时间: 2024-02-27 20:54:25 浏览: 135
以下是将Oracle SQL转换成Spark SQL的代码:
```
WITH SPECIAL_HANDLING_AIRLINE AS (
SELECT split(PARAMETER_VALUE, ',')[pos] FROM (
SELECT PARAMETER_VALUE, posexplode(split(PARAMETER_VALUE, ','))
FROM FM_APPLICATION_PARAMETERS
WHERE PARAMETER_CODE = 'TONNAGE_SPECIAL_HANDLING_AIRLINE'
)
),
SPECIAL_REVENUE_TYPE AS (
SELECT split(PARAMETER_VALUE, ',')[pos] FROM (
SELECT PARAMETER_VALUE, posexplode(split(PARAMETER_VALUE, ','))
FROM FM_APPLICATION_PARAMETERS
WHERE PARAMETER_CODE = 'TONNAGE_SPECIAL_REVENUE_TYPE'
)
),
SPECIAL_SHIPMENT_FLOW_TYPE AS (
SELECT split(PARAMETER_VALUE, ',')[pos] FROM (
SELECT PARAMETER_VALUE, posexplode(split(PARAMETER_VALUE, ','))
FROM FM_APPLICATION_PARAMETERS
WHERE PARAMETER_CODE = 'TONNAGE_SPECIAL_SHIPMENT_FLOW_TYPE'
)
),
SPECIAL_HANDLING_EFF_DATE AS (
SELECT to_date(PARAMETER_VALUE, 'yyyyMMdd') AS EFF_DATE
FROM FM_APPLICATION_PARAMETERS
WHERE PARAMETER_CODE = 'TONNAGE_SPECIAL_HANDLING_EFFECTIVE_DATE'
)
SELECT * FROM SPECIAL_HANDLING_AIRLINE;
```
注意:Spark SQL不支持Oracle SQL的所有函数和语法,因此需要根据具体情况进行转换。在这个例子中,我们使用了split函数和posexplode函数来实现Oracle SQL的regexp_substr函数和CONNECT BY LEVEL子句。同时,我们将to_date函数的格式参数从'YYYYMMDD'改为'yyyyMMdd'。
阅读全文