# SMS2 with CSV no BIND(IF....)?

**URL:** <https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805>\
**Category:** Support\
**Created:** [November 23, 2020, 5:21am UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805 "2020-11-23T05:21:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![conranc](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@conranc](https://community.stardog.com/u/conranc)\
**Post date:** [November 23, 2020, 5:21am UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/1 "2020-11-23T05:21:55Z")

</div>

We've been experimenting with CSV import using SMS2 mapping as an alternative to TARQL ([http://tarql.github.io/](http://tarql.github.io/)) .

We've found however that SMS2 mappings don't seem to support **BIND(IF...)** expressions which makes mapping based on a decision using the column value impossible.

eg  
mapping "special" values to a particular value/URI  
BIND(IF( ?employmentType=1, "FULL TIME" , "PART TIME") as ?jobString),

Any plans on supporting IF in BIND?

(Apart from this issue it does appear that it could be a viable alternative to TARQL)

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [November 23, 2020, 3:36pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/2 "2020-11-23T15:36:13Z")

</div>

Hi!

This is a supported expression. What problem are you seeing?

---

<div class="post-metadata">

**Author:** ![conranc](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@conranc](https://community.stardog.com/u/conranc)\
**Post date:** [November 23, 2020, 9:55pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/3 "2020-11-23T21:55:04Z")

</div>

We're finding that anywhere where we've used BIND(IF... the target variable is never resolved (ie missing from the CONSTRUCT output).  
eg

```auto
BIND (IF(?CASUAL = "0" && ?FULLTIME = "0",?noemployment,
			IF(?CASUAL = "1", URI(CONCAT('http://test.org/Employment/Casual')),
			URI(CONCAT('http:/test.org/Employment/Fulltime')))) as ?emptype)

```

?emptype is never resolved.  
(Even tried changing the test to = 0 in case it was converting the text value to a number)  
All other BINDs are resolving as expected.

example of CSV

```auto
FILE,YEAR,RECID,SA1,MB,BDAY,BYEAR,SEX,INDUSTRY,CASUAL,FULLTIME,HOURS,PAYRATE,AWE
A,2011,A000001,10929,1092903,168,1954,2,4,0,0,17,35.00,595.00
A,2011,A000002,10981,1098109,26,1998,1,1,0,1,40,40.00,1600.00
A,2011,A000006,10768,1076809,168,1990,2,2,1,0,40,43.20,1728.00

```

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [November 23, 2020, 9:59pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/4 "2020-11-23T21:59:19Z")

</div>

Thanks for the details. We'll take a look.

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [November 23, 2020, 10:08pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/5 "2020-11-23T22:08:15Z")

</div>

Where is `?noemployment` declared? Does it work if you replace that with a constant value?

---

<div class="post-metadata">

**Author:** ![conranc](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@conranc](https://community.stardog.com/u/conranc)\
**Post date:** [November 23, 2020, 10:23pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/6 "2020-11-23T22:23:49Z")

</div>

?noemployment is not declared so should not be resolved (ie the triple that uses that variable in the CONSTRUCT  
eg vars:employmentType ?emptype;  
would not be created).  
So, in the example we don't want ?emptype to resolve if both CASUAL & FULLTIME values are both 0.

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [November 23, 2020, 10:30pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/7 "2020-11-23T22:30:39Z")

</div>

Thanks. I've reproduced the issue. As a workaround, you can BIND something which creates an error, eg `BIND(integer("X") as ?noemployment)`. We'll get this fixed shortly.

---

<div class="post-metadata">

**Author:** ![conranc](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@conranc](https://community.stardog.com/u/conranc)\
**Post date:** [November 23, 2020, 10:31pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/8 "2020-11-23T22:31:22Z")

</div>

Thanks - will give that a try.

---

<div class="post-metadata">

**Author:** ![conranc](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@conranc](https://community.stardog.com/u/conranc)\
**Post date:** [November 23, 2020, 11:02pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/9 "2020-11-23T23:02:10Z")

</div>

That works thanks Jess. We will use that for now 👍

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [November 23, 2020, 11:31pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/10 "2020-11-23T23:31:31Z")

</div>

Glad it's working. Thanks again for reporting it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [December 7, 2020, 11:31pm UTC](https://community.stardog.com/t/sms2-with-csv-no-bind-if/2805/11 "2020-12-07T23:31:33Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
