Loading multiple files from S3 to Redshift, query completing no data in tablesHow to return multiple values from a function?Importing files from different folderHow can I open multiple files using “with open” in Python?How to install packages using pip according to the requirements.txt file from a local directory?How do I write JSON data to a file?Redshift load for snappy compressed fileloading the bulk data from s3 to redshiftUsing multiple manifest files to load to Redshift from S3?Python loads data from Redshift to S3JSON Data loading into Redshift Table

Salesforce bug enabled "Modify All"

VHDL: Why is it hard to desgin a floating point unit in hardware?

AD: Unable to perform remote desktop logon

Why is the Psionic Artificer considered to be better than all other tier 1 classes?

Ways to spot non-sentient, non-conscious, telepathic shapeshifters

(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?

Is there a filesystem that keep track of all version without snapshot?

Why do testers need root cause analysis?

Nunc est bibendum: gerund or gerundive?

Is a world with one country feeding everyone possible?

Shell builtin `printf` line limit?

How do you earn the reader's trust?

Are there historical examples of audiences drawn to a work that was "so bad it's good"?

If change in free energy (G) is positive, how do those reactions still occur?

What was the primary motivation for a historical figure like Xenophon to create an extensive collection of written material?

Is ideal gas incompressible?

If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?

Must every right-inverse of a linear transformation be a linear transformation?

size of pointers and architecture

Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?

Is there any mention of ghosts who live outside the Hogwarts castle?

Keeping the dodos out of the field

Real Analysis: Proof of the equivalent definitions of the derivative.

nginx conf: http2 module not working in Chrome in ubuntu 18.04



Loading multiple files from S3 to Redshift, query completing no data in tables


How to return multiple values from a function?Importing files from different folderHow can I open multiple files using “with open” in Python?How to install packages using pip according to the requirements.txt file from a local directory?How do I write JSON data to a file?Redshift load for snappy compressed fileloading the bulk data from s3 to redshiftUsing multiple manifest files to load to Redshift from S3?Python loads data from Redshift to S3JSON Data loading into Redshift Table






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a script firing from lambda that executes the following query:



 COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'


However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?



Here is the code being executed in case this isn't a query issue:



create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)


Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.










share|improve this question
























  • executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them

    – Shenanigator
    Mar 23 at 20:46











  • I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?

    – Shenanigator
    Mar 23 at 21:11

















0















I have a script firing from lambda that executes the following query:



 COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'


However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?



Here is the code being executed in case this isn't a query issue:



create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)


Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.










share|improve this question
























  • executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them

    – Shenanigator
    Mar 23 at 20:46











  • I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?

    – Shenanigator
    Mar 23 at 21:11













0












0








0








I have a script firing from lambda that executes the following query:



 COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'


However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?



Here is the code being executed in case this isn't a query issue:



create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)


Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.










share|improve this question
















I have a script firing from lambda that executes the following query:



 COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'


However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?



Here is the code being executed in case this isn't a query issue:



create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)


Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.







python amazon-s3 amazon-redshift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 21:57







Shenanigator

















asked Mar 23 at 20:35









ShenanigatorShenanigator

293117




293117












  • executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them

    – Shenanigator
    Mar 23 at 20:46











  • I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?

    – Shenanigator
    Mar 23 at 21:11

















  • executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them

    – Shenanigator
    Mar 23 at 20:46











  • I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?

    – Shenanigator
    Mar 23 at 21:11
















executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them

– Shenanigator
Mar 23 at 20:46





executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them

– Shenanigator
Mar 23 at 20:46













I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?

– Shenanigator
Mar 23 at 21:11





I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?

– Shenanigator
Mar 23 at 21:11












1 Answer
1






active

oldest

votes


















0














The answer is .... apparently order matters to sqlalchemy:



create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execution_options(autocommit=True).execute(loadQuery)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)


you'll notice the order change to the auto_commit.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318114%2floading-multiple-files-from-s3-to-redshift-query-completing-no-data-in-tables%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The answer is .... apparently order matters to sqlalchemy:



    create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

    loadQuery = '''
    COPY .
    FROM '/'
    iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
    TRUNCATECOLUMNS
    JSON 'auto'
    EMPTYASNULL
    TIMEFORMAT 'auto'
    DATEFORMAT 'auto'
    COMPUPDATE OFF
    STATUPDATE ON
    '''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

    with igers.connect() as conn:
    try :
    conn.execute(drop_table)
    print('completed drop table')
    conn.execute(ddl_str)
    print('completed create table')
    conn.execution_options(autocommit=True).execute(loadQuery)
    print('completed load query')
    for row in range(len(groupPerms)) :
    perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
    conn.execute(perms_statement)
    print('completed grant group permissions')
    conn.close()
    except exc.SQLAlchemyError as e :
    print(e)


    you'll notice the order change to the auto_commit.






    share|improve this answer



























      0














      The answer is .... apparently order matters to sqlalchemy:



      create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

      loadQuery = '''
      COPY .
      FROM '/'
      iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
      TRUNCATECOLUMNS
      JSON 'auto'
      EMPTYASNULL
      TIMEFORMAT 'auto'
      DATEFORMAT 'auto'
      COMPUPDATE OFF
      STATUPDATE ON
      '''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

      with igers.connect() as conn:
      try :
      conn.execute(drop_table)
      print('completed drop table')
      conn.execute(ddl_str)
      print('completed create table')
      conn.execution_options(autocommit=True).execute(loadQuery)
      print('completed load query')
      for row in range(len(groupPerms)) :
      perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
      conn.execute(perms_statement)
      print('completed grant group permissions')
      conn.close()
      except exc.SQLAlchemyError as e :
      print(e)


      you'll notice the order change to the auto_commit.






      share|improve this answer

























        0












        0








        0







        The answer is .... apparently order matters to sqlalchemy:



        create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

        loadQuery = '''
        COPY .
        FROM '/'
        iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
        TRUNCATECOLUMNS
        JSON 'auto'
        EMPTYASNULL
        TIMEFORMAT 'auto'
        DATEFORMAT 'auto'
        COMPUPDATE OFF
        STATUPDATE ON
        '''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

        with igers.connect() as conn:
        try :
        conn.execute(drop_table)
        print('completed drop table')
        conn.execute(ddl_str)
        print('completed create table')
        conn.execution_options(autocommit=True).execute(loadQuery)
        print('completed load query')
        for row in range(len(groupPerms)) :
        perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
        conn.execute(perms_statement)
        print('completed grant group permissions')
        conn.close()
        except exc.SQLAlchemyError as e :
        print(e)


        you'll notice the order change to the auto_commit.






        share|improve this answer













        The answer is .... apparently order matters to sqlalchemy:



        create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")

        loadQuery = '''
        COPY .
        FROM '/'
        iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
        TRUNCATECOLUMNS
        JSON 'auto'
        EMPTYASNULL
        TIMEFORMAT 'auto'
        DATEFORMAT 'auto'
        COMPUPDATE OFF
        STATUPDATE ON
        '''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)

        with igers.connect() as conn:
        try :
        conn.execute(drop_table)
        print('completed drop table')
        conn.execute(ddl_str)
        print('completed create table')
        conn.execution_options(autocommit=True).execute(loadQuery)
        print('completed load query')
        for row in range(len(groupPerms)) :
        perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
        conn.execute(perms_statement)
        print('completed grant group permissions')
        conn.close()
        except exc.SQLAlchemyError as e :
        print(e)


        you'll notice the order change to the auto_commit.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 22:21









        ShenanigatorShenanigator

        293117




        293117





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318114%2floading-multiple-files-from-s3-to-redshift-query-completing-no-data-in-tables%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해