buen dia inges..
Tengo un problema al querer pasar mi variable a una sentencia SQL usando spark.sql, en python.
mi_variable = "mi_set_name"
mi_variable = "mi_set_name"
yY tengo una consulta sql de esta manera:
dfNode = spark.sql(''' SELECT n.*, h2.settype
FROM SETNODE_SubsetenSet n
inner join SETHEADER_CabeceraeIndiceSet h2 on n.subsetcls = h2.setclass and n.subsetscls = h2.subclass and n.subsetname = h2.setname and n.mand = h2.mand
where n.MAND = '400'
AND n.subclass = 'FEBR'
AND n.SETNAME = mi_variable
AND n.setclass = '0101' ''').collect()
dfNode = spark.sql(''' SELECT n.*, h2.settype
FROM SETNODE_SubsetenSet n
inner join SETHEADER_CabeceraeIndiceSet h2 on n.subsetcls = h2.setclass and n.subsetscls = h2.subclass and n.subsetname = h2.setname and n.mand = h2.mand
where n.MAND = '400'
AND n.subclass = 'FEBR'
AND n.SETNAME = mi_variable
AND n.setclass = '0101' ''').collect()
dfNode = spark.sql(''' SELECT n.*, h2.settype
FROM SETNODE_SubsetenSet n
inner join SETHEADER_CabeceraeIndiceSet h2 on n.subsetcls = h2.setclass and n.subsetscls = h2.subclass and n.subsetname = h2.setname and n.mand = h2.mand
where n.MAND = '400'
AND n.subclass = 'FEBR'
AND n.SETNAME = {}
AND n.setclass = '0101' '''.format(mi_variable)).collect()
dfNode = spark.sql(''' SELECT n.*, h2.settype
FROM SETNODE_SubsetenSet n
inner join SETHEADER_CabeceraeIndiceSet h2 on n.subsetcls = h2.setclass and n.subsetscls = h2.subclass and n.subsetname = h2.setname and n.mand = h2.mand
where n.MAND = '400'
AND n.subclass = 'FEBR'
AND n.SETNAME = {}
AND n.setclass = '0101' '''.format(mi_variable)).collect()
Cualquier informacion que requieran estaré al pendiente
Saludos.