user3350280
user3350280

Reputation: 95

Passing parameter in sqoop

Below is my sqoop cmd in shell script,

sqoop import --connect 'jdbc:sqlserver://190.148.155.91:1433;username=****;password=****;database=Testdb' --query 'Select DimFreqCellRelationID,OSSC_RC, MeContext, ENodeBFunction,EUtranCellFDD,EUtranFreqRelation, EUtranCellRelation FROM dbo.DimCellRelation WHERE DimFreqCellRelationID > **$maxval** and $CONDITIONS'  --split-by OSS --target-dir /testval;

Before executing this command, i have assigned a value to $maxval , when I execute sqoop cmd value should get passed in place of $maxval. But thats not happning. Is it possible to pass parameter through sqoop. Can you please let me know if you have any suggestion to achieve this logic?

Upvotes: 0

Views: 1959

Answers (1)

Jarek Jarcec Cecho
Jarek Jarcec Cecho

Reputation: 1726

I believe that the problem you are seeing is with incorrect enclosing. Using single quotes (') will prohibit bash to perform any substitutions. You need to use double quotes (") if you want to use variables inside the parameter. However you also have to be careful as you do not want to substitute the $CONDITIONS placeholder. Try it without Sqoop:

jarcec@Odie ~ % echo '$maxval and $CONDITIONS'
$maxval and $CONDITIONS
jarcec@Odie ~ % echo "$maxval and $CONDITIONS"
 and 
jarcec@Odie ~ % echo "$maxval and $CONDITIONS"
jarcec@Odie ~ % export maxval=30
jarcec@Odie ~ % echo "$maxval and $CONDITIONS"
30 and 
jarcec@Odie ~ % echo "$maxval and \$CONDITIONS"
30 and $CONDITIONS

Upvotes: 1

Related Questions