# Sql\_last\_value doesn't refresh

**URL:** https://discuss.elastic.co/t/sql-last-value-doesnt-refresh/127787
**Category:** Logstash
**Created:** [April 12, 2018, 10:20am UTC](https://discuss.elastic.co/t/sql-last-value-doesnt-refresh/127787 "2018-04-12T10:20:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![woshitom](https://avatars.discourse-cdn.com/v4/letter/w/a587f6/32.png) [@woshitom](https://discuss.elastic.co/u/woshitom)
#### Post date: [April 12, 2018, 10:20am UTC](https://discuss.elastic.co/t/sql-last-value-doesnt-refresh/127787/1 "2018-04-12T10:20:05Z")

</div>

I'm importing data from a postgresql database to elasticsearch using logstash.

My input looks like:

```
input {
    jdbc {
        jdbc_connection_string => "***"
        jdbc_user => "***"
        jdbc_password => "***"
        jdbc_driver_library => "/path/postgresql-42.1.4.jar"
        jdbc_driver_class => "org.postgresql.Driver"
        use_column_value => true
        tracking_column => "updated_at"
        tracking_column_type => "timestamp"
        clean_run => true 
        last_run_metadata_path => "/path/dump_shops.logstash_jdbc_last_run"
        
        statement => "
            select
                'shop' as type,
                id_catalog_shop id_shop,
                fk_catalog_company,
                'company' shop,
                address,
                lon,
                lat,
                updated_at,
                active,
                'category' as category,
                to_json(opening_hours::text)#>>'{}' as opening_hours
            from catalog_shop
		    WHERE updated_at > :sql_last_value        
	    "
         
    }
}

```

When I'm running the corresponding conf file using this command:

`sudo /usr/share/logstash/bin/logstash -f /path/dump_shops.conf --path.data /path/dump_shops/`

The script is being executed and I can see that the :sql\_last\_value is equal to its default value (jan 1st 1970) instead of the last updated\_at value :

```
    select
        'shop' as type,
        id_catalog_shop id_shop,
        fk_catalog_company,
        'company' shop,
        address,
        lon,
        lat,
        updated_at,
        active,
        'category' as category,
        to_json(opening_hours::text)#>>'{}' as opening_hours
    from catalog_shop
	    WHERE updated_at > '1970-01-01 00:00:00.000000+0000' 

```

On the other hand my dump\_shops.logstash\_jdbc\_last\_run **is well being updated** :

```
vim /path/dump_shops.logstash_jdbc_last_run
--- 2018-04-12 09:53:26.040731000 +00:00

```

I tried to delete dump\_shops.logstash\_jdbc\_last\_run but still, when I'm running the script :sql\_last\_value is still equal to jan 1st 1970 while dump\_shops.logstash\_jdbc\_last\_run is well being updated

---

<div class="post-metadata">

### Author: ![woshitom](https://avatars.discourse-cdn.com/v4/letter/w/a587f6/32.png) [@woshitom](https://discuss.elastic.co/u/woshitom)
#### Post date: [April 12, 2018, 12:33pm UTC](https://discuss.elastic.co/t/sql-last-value-doesnt-refresh/127787/2 "2018-04-12T12:33:09Z")

</div>

It's because clean\_run was set to true instead of false, it's now working.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 10, 2018, 12:33pm UTC](https://discuss.elastic.co/t/sql-last-value-doesnt-refresh/127787/3 "2018-05-10T12:33:21Z")

</div>

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