---
title: "Expressions Tutorial: Usage Notes and Next Steps"
description: "Caveats for using Aerospike expressions, tutorial takeaways, cleanup, and further resources."
---

# Usage notes and next steps

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

## Usage notes

-   Errors during evaluation:
    
    -   Errors such as type match and bin existence can be checked using `cond` to avoid run time evaluation errors:
        
        -   [Java](#tab-panel-5715)
        -   [Python](#tab-panel-5716)
        -   [Go](#tab-panel-5717)
        -   [C#](#tab-panel-5718)
        -   [Node.js](#tab-panel-5719)
        -   [Rust](#tab-panel-5720)
        
        ```java
        // If bin "a" is an integer, return true if the value of "a" is > 1, otherwise return false
        
        Exp.cond(
        
            Exp.eq( // check if the bin is of type int
        
                Exp.binType("a"),
        
                Exp.val(ParticleType.INTEGER)),
        
            Exp.eq( // perform int comparison
        
                Exp.intBin("a"),
        
                Exp.val(1)),
        
            Exp.val(false)); // default is false
        ```
        
        ```python
        exp.Cond(
        
            exp.Eq(  # check if the bin is of type int
        
                exp.BinType("a"),
        
                aerospike.AS_BYTES_INTEGER),
        
            exp.Eq(  # perform int comparison
        
                exp.IntBin("a"), 1),
        
            False)  # default is false
        ```
        
        ```go
        as.ExpCond(
        
            as.ExpEq( // check if the bin is of type int (ParticleType.INTEGER == 1)
        
                as.ExpBinType("a"),
        
                as.ExpIntVal(1)),
        
            as.ExpEq( // perform int comparison
        
                as.ExpIntBin("a"), as.ExpIntVal(1)),
        
            as.ExpBoolVal(false)) // default is false
        ```
        
        ```csharp
        Exp.Cond(
        
            Exp.EQ( // check if the bin is of type int (ParticleType.INTEGER == 1)
        
                Exp.BinType("a"),
        
                Exp.Val(1)),
        
            Exp.EQ( // perform int comparison
        
                Exp.IntBin("a"), Exp.Val(1)),
        
            Exp.Val(false)); // default is false
        ```
        
        ```js
        exp.cond(
        
            exp.eq( // check if the bin is of type int (ParticleType.INTEGER == 1)
        
                exp.binType('a'),
        
                exp.int(1)),
        
            exp.eq( // perform int comparison
        
                exp.binInt('a'), exp.int(1)),
        
            exp.bool(false)) // default is false
        ```
        
        ```rust
        cond(vec![
        
            eq( // check if the bin is of type int (ParticleType.INTEGER == 1)
        
                bin_type("a".to_string()),
        
                int_val(ParticleType::INTEGER as i64)),
        
            eq( // perform int comparison
        
                int_bin("a".to_string()), int_val(1)),
        
            bool_val(false), // default is false
        
        ])
        ```
        
-   All branches of a `cond` expression must evaluate to the same type, otherwise the condition will always fail.
    
-   `cond` expressions must always have a default value. This can be `unknown` which matches every type.
    
    -   Filter expressions treat the final unknown value as false, whereas in operation expressions it results in an error.
    -   If appropriate, evaluation failure can be ignored while performing multiple `operate` operations by setting the flags argument in `ExpOperation.read` or `.write` to `ExpReadFlags.EVAL_NO_FAIL` or `ExpWriteFlags.EVAL_NO_FAIL` respectively.
-   Constructs like loops and iterators over record bins or CDT elements are not currently supported. General manipulation of data beyond what is available in the APIs also is not supported.
    

## Takeaways and conclusion

The tutorial described expressions capabilities in Aerospike. It explained the scope and syntax, and described the key components and constructs. It provided code examples for how to work with expressions in two client uses: filter expressions and operation expressions.

The enhanced capabilities in filtering expressions allow records to be processed more efficiently by avoiding the need for more expensive client or UDF based processing. New capabilities include access to metadata, bin data, powerful APIs, as well as enhanced arithmetic and other operators.

Operation expressions can eliminate the need to read before update by allowing read, processing for update, and update to happen on the server side in the same request. This saves a round-trip and transfer of potentially large data.

Expressions provide powerful capabilities; evaluate and use them if they are suitable and provide better performance for your use case over UDFs and client-side processing.

## Cleaning up

Remove tutorial data and close connection.

-   [Java](#tab-panel-5721)
-   [Python](#tab-panel-5722)
-   [Go](#tab-panel-5723)
-   [C#](#tab-panel-5724)
-   [Node.js](#tab-panel-5725)
-   [Rust](#tab-panel-5726)

```java
truncateTestData();

client.close();

System.out.println("Removed tutorial data and closed server connection.");
```

> Output:
> 
> Removed tutorial data and closed server connection.

```python
truncate_test_data()

client.close()

print("Removed tutorial data and closed server connection.")
```

> Output:
> 
> Removed tutorial data and closed server connection.

```go
truncateTestData()

client.Close()

fmt.Println("Removed tutorial data and closed server connection.")
```

> Output:
> 
> Removed tutorial data and closed server connection.

```csharp
TruncateTestData();

client.Close();

Console.WriteLine("Removed tutorial data and closed server connection.");
```

> Output:
> 
> Removed tutorial data and closed server connection.

```js
await truncateTestData();

await client.close();

console.log('Removed tutorial data and closed server connection.');
```

> Output:
> 
> Removed tutorial data and closed server connection.

```rust
truncate_test_data(&client).await;

client.close().await?;

println!("Removed tutorial data and closed server connection.");
```

> Output:
> 
> Removed tutorial data and closed server connection.

## Further exploration and resources

Here are some links for further exploration.

### Resources

-   Docs
    -   [Aerospike Expressions Guide](https://aerospike.com/docs/develop/expressions/)
-   Related tutorials
    -   [Read-Write Transactions with R-M-W Pattern (Python)](https://aerospike.com/docs/develop/tutorials/intro/read-modify-write-python)
    -   [Implementing SQL Operations: SELECT](https://aerospike.com/docs/develop/tutorials/sql/sql-select-java),
    -   [Implementing SQL Operations: CREATE, UPDATE, DELETE](https://aerospike.com/docs/develop/tutorials/sql/sql-update-java)
    -   [Working with Lists](https://aerospike.com/docs/develop/tutorials/cdt/working-with-lists-java)
    -   [Working with Maps](https://aerospike.com/docs/develop/tutorials/cdt/working-with-maps-java)
-   GitHub repos
    -   [Java code examples](https://github.com/aerospike/aerospike-client-java/tree/master/examples/src/com/aerospike/examples)
    -   [Java Client](https://www.aerospike.com/docs/client/java/index.html)